X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=xmalloc.c;h=bc6be9fb112841f1f22fc9c6f7588c45003f4e45;hb=fdff840db02a5d403e1423b070fd43cbbc52a07c;hp=8c97b0f95f5d0921dbc081b2f7569b257528f98f;hpb=ab7c095ffc2e9d6409fd2983b5462bb3d4609e60;p=acre diff --git a/xmalloc.c b/xmalloc.c index 8c97b0f..bc6be9f 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -23,7 +23,9 @@ */ #include "xmalloc.h" + #include +#include /* Allocate memory using malloc(), checking for errors. * @@ -60,3 +62,17 @@ xrealloc (void *ptr, size_t size) 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; +}