3 static char elsieid
[] = "@(#)ialloc.c 8.28";
4 #endif /* !defined NOID */
5 #endif /* !defined lint */
11 #define nonzero(n) (((n) == 0) ? 1 : (n))
13 char * icalloc
P((int nelem
, int elsize
));
14 char * icatalloc
P((char * old
, const char * new));
15 char * icpyalloc
P((const char * string
));
16 char * imalloc
P((int n
));
17 void * irealloc
P((void * pointer
, int size
));
18 void ifree
P((char * pointer
));
24 return malloc((size_t) nonzero(n
));
28 icalloc(nelem
, elsize
)
32 if (nelem
== 0 || elsize
== 0)
34 return calloc((size_t) nelem
, (size_t) elsize
);
38 irealloc(pointer
, size
)
44 return realloc((void *) pointer
, (size_t) nonzero(size
));
50 const char * const new;
52 register char * result
;
53 register int oldsize
, newsize
;
55 newsize
= (new == NULL
) ? 0 : strlen(new);
58 else if (newsize
== 0)
60 else oldsize
= strlen(old
);
61 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
63 (void) strcpy(result
+ oldsize
, new);
69 const char * const string
;
71 return icatalloc((char *) NULL
, string
);