7600 zfs rollback should pass target snapshot to kernel
[unleashed.git] / usr / src / cmd / zic / ialloc.c
blob9b769edee018104ff072a3cd725646f1218f6315
1 #pragma ident "%Z%%M% %I% %E% SMI"
3 /* static char elsieid[] = "@(#)ialloc.c 8.29"; */
5 /*LINTLIBRARY*/
7 #include "private.h"
9 #define nonzero(n) (((n) == 0) ? 1 : (n))
11 char *
12 imalloc(n)
13 const int n;
15 return (malloc((size_t) nonzero(n)));
18 void *
19 irealloc(pointer, size)
20 void * const pointer;
21 const int size;
23 if (pointer == NULL)
24 return (imalloc(size));
25 return (realloc((void *) pointer, (size_t) nonzero(size)));
28 char *
29 icatalloc(old, new)
30 char * const old;
31 const char * const new;
33 register char * result;
34 register int oldsize, newsize;
36 newsize = (new == NULL) ? 0 : strlen(new);
37 if (old == NULL)
38 oldsize = 0;
39 else if (newsize == 0)
40 return (old);
41 else oldsize = strlen(old);
42 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
43 if (new != NULL)
44 (void) strcpy(result + oldsize, new);
45 return (result);
48 char *
49 icpyalloc(string)
50 const char * const string;
52 return (icatalloc((char *) NULL, string));
55 void
56 ifree(p)
57 char * const p;
59 if (p != NULL)
60 (void) free(p);