]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/tzcode/ialloc.c
ICU-57163.0.1.tar.gz
[apple/icu.git] / icuSources / tools / tzcode / ialloc.c
CommitLineData
73c04bcf
A
1/*
2** This file is in the public domain, so clarified as of
3** 2006-07-17 by Arthur David Olson.
4*/
5
73c04bcf
A
6/*LINTLIBRARY*/
7
8#include "private.h"
9
73c04bcf 10char *
b331163b 11icatalloc(char *const old, const char *const new)
73c04bcf
A
12{
13 register char * result;
14 register int oldsize, newsize;
15
16 newsize = (new == NULL) ? 0 : strlen(new);
17 if (old == NULL)
18 oldsize = 0;
19 else if (newsize == 0)
20 return old;
21 else oldsize = strlen(old);
b331163b 22 if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
73c04bcf
A
23 if (new != NULL)
24 (void) strcpy(result + oldsize, new);
25 return result;
26}
27
28char *
b331163b 29icpyalloc(const char *const string)
73c04bcf 30{
b331163b 31 return icatalloc(NULL, string);
73c04bcf 32}