]>
git.saurik.com Git - apple/system_cmds.git/blob - zic.tproj/ialloc.c
fabe0c64e68f442804c41e50b1e2b3923c3f9008
4 __unused
static const char elsieid
[] = "@(#)ialloc.c 8.29";
5 #endif /* !defined NOID */
6 #endif /* !defined lint */
9 __unused
static const char rcsid
[] =
10 "$FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.6 2000/11/28 18:18:56 charnier Exp $";
17 #define nonzero(n) (((n) == 0) ? 1 : (n))
20 imalloc(const size_t n
)
22 return malloc(nonzero(n
));
26 icalloc(size_t nelem
, size_t elsize
)
28 if (nelem
== 0 || elsize
== 0)
30 return calloc(nelem
, elsize
);
34 irealloc(void * const pointer
, const size_t size
)
38 return realloc((void *) pointer
, nonzero(size
));
42 icatalloc(char * const old
, const char * const new)
45 size_t oldsize
, newsize
;
47 newsize
= (new == NULL
) ? 0 : strlen(new);
50 else if (newsize
== 0)
52 else oldsize
= strlen(old
);
53 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
55 (void) strcpy(result
+ oldsize
, new);
60 icpyalloc(const char * const string
)
62 return icatalloc((char *) NULL
, string
);
73 icfree(char * const p
)