2 * This file is in the public domain, so clarified as of
3 * 2006-07-17 by Arthur David Olson.
9 #include "postgres_fe.h"
14 #define nonzero(n) (((n) == 0) ? 1 : (n))
19 return malloc((size_t) nonzero(n
));
23 icalloc(int nelem
, int elsize
)
25 if (nelem
== 0 || elsize
== 0)
27 return calloc((size_t) nelem
, (size_t) elsize
);
31 irealloc(void *pointer
, int size
)
35 return realloc((void *) pointer
, (size_t) nonzero(size
));
39 icatalloc(char *old
, const char *new)
45 newsize
= (new == NULL
) ? 0 : strlen(new);
48 else if (newsize
== 0)
51 oldsize
= strlen(old
);
52 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
54 (void) strcpy(result
+ oldsize
, new);
59 icpyalloc(const char *string
)
61 return icatalloc((char *) NULL
, string
);