(dl_main): Fixtypo.
[glibc.git] / time / ialloc.c
blob8a0c7015789022a3dbf82bdf2257bd8fb0512975
1 #ifndef lint
2 #ifndef NOID
3 static char elsieid[] = "@(#)ialloc.c 8.29";
4 #endif /* !defined NOID */
5 #endif /* !defined lint */
7 /*LINTLIBRARY*/
9 #include "private.h"
11 #define nonzero(n) (((n) == 0) ? 1 : (n))
13 char *
14 imalloc(n)
15 const int n;
17 return malloc((size_t) nonzero(n));
20 char *
21 icalloc(nelem, elsize)
22 int nelem;
23 int elsize;
25 if (nelem == 0 || elsize == 0)
26 nelem = elsize = 1;
27 return calloc((size_t) nelem, (size_t) elsize);
30 void *
31 irealloc(pointer, size)
32 void * const pointer;
33 const int size;
35 if (pointer == NULL)
36 return imalloc(size);
37 return realloc((void *) pointer, (size_t) nonzero(size));
40 char *
41 icatalloc(old, new)
42 char * const old;
43 const char * const new;
45 register char * result;
46 register int oldsize, newsize;
48 newsize = (new == NULL) ? 0 : strlen(new);
49 if (old == NULL)
50 oldsize = 0;
51 else if (newsize == 0)
52 return old;
53 else oldsize = strlen(old);
54 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
55 if (new != NULL)
56 (void) strcpy(result + oldsize, new);
57 return result;
60 char *
61 icpyalloc(string)
62 const char * const string;
64 return icatalloc((char *) NULL, string);
67 void
68 ifree(p)
69 char * const p;
71 if (p != NULL)
72 (void) free(p);
75 void
76 icfree(p)
77 char * const p;
79 if (p != NULL)
80 (void) free(p);