tools/llvm: Do not build with symbols
[minix3.git] / lib / libc / time / ialloc.c
blob5b7dfe0242652498ac8317a2cdfaec712b987e88
1 /* $NetBSD: ialloc.c,v 1.9 2012/10/26 18:29:34 christos Exp $ */
2 /*
3 ** This file is in the public domain, so clarified as of
4 ** 2006-07-17 by Arthur David Olson.
5 */
7 #if HAVE_NBTOOL_CONFIG_H
8 #include "nbtool_config.h"
9 #endif
11 #include <sys/cdefs.h>
13 #if 0
14 static char elsieid[] = "@(#)ialloc.c 8.30";
15 #else
16 __RCSID("$NetBSD: ialloc.c,v 1.9 2012/10/26 18:29:34 christos Exp $");
17 #endif
19 #include "private.h"
21 char *
22 icatalloc(char *const old, const char *const new)
24 char * result;
25 int oldsize, newsize;
27 newsize = (new == NULL) ? 0 : strlen(new);
28 if (old == NULL)
29 oldsize = 0;
30 else if (newsize == 0)
31 return old;
32 else
33 oldsize = strlen(old);
34 if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
35 if (new != NULL)
36 (void) strcpy(result + oldsize, new); /* XXX strcpy is safe */
37 return result;
40 char *
41 icpyalloc(const char *const string)
43 return icatalloc(NULL, string);