Which is analagous to xmalloc and friends.
*/
#include "xmalloc.h"
+
#include <stdio.h>
+#include <string.h>
/* Allocate memory using malloc(), checking for errors.
*
return ret;
}
+
+char *
+xstrdup (const char *s)
+{
+ char *ret;
+
+ ret = strdup (s);
+ if (ret == NULL) {
+ fprintf (stderr, "Error: out of memory. Exiting.\n");
+ exit (1);
+ }
+
+ return ret;
+}
((size) && (unsigned) (nmemb) >= INT32_MAX / (unsigned) (size) ? NULL : \
xrealloc(ptr, (unsigned) (nmemb) * (unsigned) (size)))
+char *
+xstrdup (const char *s);
+
#endif /* XMALLOC_H */