2 * malloc.c: safe wrappers around malloc, realloc, free, strdup
10 * smalloc should guarantee to return a useful pointer - Halibut
11 * can do nothing except die when it's out of memory anyway.
13 void *smalloc(size_t size
) {
17 fatal("out of memory");
22 * sfree should guaranteeably deal gracefully with freeing NULL
31 * srealloc should guaranteeably be able to realloc NULL
33 void *srealloc(void *p
, size_t size
) {
41 fatal("out of memory");
46 * dupstr is like strdup, but with the never-return-NULL property
47 * of smalloc (and also reliably defined in all environments :-)
49 char *dupstr(const char *s
) {
50 char *r
= smalloc(1+strlen(s
));