3 static char elsieid[] = "@(#)ialloc.c 8.19";
4 #endif /* !defined NOID */
5 #endif /* !defined lint */
12 #define NULLMAL(x) ((x) == NULL || (x) == MAL)
13 #else /* !defined MAL */
14 #define NULLMAL(x) ((x) == NULL)
15 #endif /* !defined MAL */
17 #define nonzero(n) (((n) == 0) ? 1 : (n))
19 char * icalloc P((int nelem, int elsize));
20 char * icatalloc P((char * old, const char * new));
21 char * icpyalloc P((const char * string));
22 char * imalloc P((int n));
23 char * irealloc P((char * pointer, int size));
24 void ifree P((char * pointer));
31 register char * result;
33 result = malloc((alloc_size_t) nonzero(n));
34 return NULLMAL(result) ? NULL : result;
35 #else /* !defined MAL */
36 return malloc((alloc_size_t) nonzero(n));
37 #endif /* !defined MAL */
41 icalloc(nelem, elsize)
45 if (nelem == 0 || elsize == 0)
47 return calloc((alloc_size_t) nelem, (alloc_size_t) elsize);
51 irealloc(pointer, size)
57 return realloc((genericptr_t) pointer, (alloc_size_t) nonzero(size));
63 const char * const new;
65 register char * result;
66 register oldsize, newsize;
68 newsize = NULLMAL(new) ? 0 : strlen(new);
71 else if (newsize == 0)
73 else oldsize = strlen(old);
74 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
76 (void) strcpy(result + oldsize, new);
82 const char * const string;
84 return icatalloc((char *) NULL, string);