]>
git.cameronkatri.com Git - apple_cmds.git/blob - system_cmds/zic.tproj/ialloc.c
2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
8 static const char elsieid
[] = "@(#)ialloc.c 8.30";
9 #endif /* !defined NOID */
10 #endif /* !defined lint */
13 static const char rcsid
[] =
14 "$FreeBSD: head/contrib/tzcode/zic/ialloc.c 192625 2009-05-23 06:31:50Z edwin $";
21 #define nonzero(n) (((n) == 0) ? 1 : (n))
27 return malloc((size_t) nonzero(n
));
31 icalloc(nelem
, elsize
)
35 if (nelem
== 0 || elsize
== 0)
37 return calloc((size_t) nelem
, (size_t) elsize
);
41 irealloc(pointer
, size
)
47 return realloc((void *) pointer
, (size_t) nonzero(size
));
53 const char * const new;
55 register char * result
;
56 register int oldsize
, newsize
;
58 newsize
= (new == NULL
) ? 0 : strlen(new);
61 else if (newsize
== 0)
63 else oldsize
= strlen(old
);
64 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
66 (void) strcpy(result
+ oldsize
, new);
72 const char * const string
;
74 return icatalloc((char *) NULL
, string
);