summaryrefslogtreecommitdiff
path: root/src/libstddjb/alloc_realloc.c
blob: 6d5c680a3a29772dbdcf18202f608dedd39dfc46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* ISC license. */

#include <stdlib.h>
#include <skalibs/alloc.h>

int alloc_realloc (char **x, size_t n)
{
  char *y = n ? realloc(*x, n) : alloc(0) ;
  if (!y) return 0 ;
  if (!n) free(*x) ;
  *x = y ;
  return 1 ;
}