skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

alloc_realloc.c (221B)


      1 /* ISC license. */
      2 
      3 #include <stdlib.h>
      4 #include <skalibs/alloc.h>
      5 
      6 int alloc_realloc (char **x, size_t n)
      7 {
      8   char *y = n ? realloc(*x, n) : alloc(0) ;
      9   if (!y) return 0 ;
     10   if (!n) free(*x) ;
     11   *x = y ;
     12   return 1 ;
     13 }