libstand: Add uuid_{from,to}_string() and uuid_create_nil() (from libc).
[dragonfly.git] / usr.sbin / zic / ialloc.c
blob4dccf6baef9bd35fd2ded8f8ffcdbd62a4976b78
1 /*
2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
4 */
6 /*
7 * $FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.5 1999/08/28 01:21:18 peter Exp $
8 */
9 /*LINTLIBRARY*/
11 #include "private.h"
13 char *
14 icatalloc(char *const old, const char * const new)
16 char *result;
17 int oldsize, newsize;
19 newsize = (new == NULL) ? 0 : strlen(new);
20 if (old == NULL)
21 oldsize = 0;
22 else if (newsize == 0)
23 return old;
24 else oldsize = strlen(old);
25 if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
26 if (new != NULL)
27 strcpy(result + oldsize, new);
28 return result;
31 char *
32 icpyalloc(const char * const string)
34 return icatalloc(NULL, string);