Radix cross Linux Package Tools

Package Tools – is a set of utilities to create, install, and update RcL packages

8 Commits   0 Branches   2 Tags
     5         kx 
     5         kx /**********************************************************************
     5         kx 
     5         kx   Copyright 2019 Andrey V.Kosteltsev
     5         kx 
     5         kx   Licensed under the Radix.pro License, Version 1.0 (the "License");
     5         kx   you may not use this file  except  in compliance with the License.
     5         kx   You may obtain a copy of the License at
     5         kx 
     5         kx      https://radix.pro/licenses/LICENSE-1.0-en_US.txt
     5         kx 
     5         kx   Unless required by applicable law or agreed to in writing, software
     5         kx   distributed under the License is distributed on an "AS IS" BASIS,
     5         kx   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
     5         kx   implied.
     5         kx 
     5         kx  **********************************************************************/
     5         kx 
     5         kx #include <config.h>
     5         kx 
     5         kx #include <stdlib.h>
     5         kx #include <stdio.h>
     5         kx #include <string.h>
     5         kx #include <errno.h>
     5         kx #include <error.h>
     5         kx #include <sys/stat.h>
     5         kx #include <sys/wait.h>
     5         kx #include <stdarg.h>
     5         kx #include <unistd.h>
     5         kx 
     5         kx #include <msglog.h>
     5         kx 
     5         kx 
     5         kx char *xstrdup( const char *str )
     5         kx {
     5         kx   char   *ret = (char *)NULL;
     5         kx   size_t  len;
     5         kx 
     5         kx   if( !str ) return ret;
     5         kx 
     5         kx   len = strlen( str ) + 1;
     5         kx 
     5         kx   ret = (char *)malloc( len );
     5         kx   if( !ret )
     5         kx     FATAL_ERROR( "Out of memory, strdup failed (tried to allocate %lu bytes)", (unsigned long)len );
     5         kx 
     5         kx   ret[len-1] = '\0';
     5         kx   ret = strncpy( ret, str, len-1 );
     5         kx   return ret;
     5         kx }
     5         kx 
     5         kx void *xmalloc( size_t size )
     5         kx {
     5         kx   void *ret = NULL;
     5         kx 
     5         kx   ret = malloc( size );
     5         kx   if( !ret )
     5         kx   {
     5         kx     FATAL_ERROR( "Out of memory, malloc failed (tried to allocate %lu bytes)", (unsigned long)size );
     5         kx   }
     5         kx   memset( ret, 0, size );
     5         kx   return ret;
     5         kx }
     5         kx 
     5         kx void *xrealloc( void *ptr, size_t size )
     5         kx {
     5         kx   void *ret = NULL;
     5         kx 
     5         kx   ret = realloc( ptr, size );
     5         kx   if( !ret && !size )
     5         kx     ret = realloc( ptr, 1 );
     5         kx   if( !ret )
     5         kx     FATAL_ERROR( "Out of memory, realloc failed" );
     5         kx   return ret;
     5         kx }