X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fstringi-map-test.c;h=a78fd56557f53a46be68ac9a32a346fe1f377acd;hb=cb08510bbbab7646bc1031427243489024d22a3b;hp=20b8ce5c2c8e85039be225bae5b377be1d94e19b;hpb=0df9cdd3df66caf4353128feff3008289cda8115;p=pspp diff --git a/tests/libpspp/stringi-map-test.c b/tests/libpspp/stringi-map-test.c index 20b8ce5c2c..a78fd56557 100644 --- a/tests/libpspp/stringi-map-test.c +++ b/tests/libpspp/stringi-map-test.c @@ -69,58 +69,6 @@ check_func (bool ok, int line) terminates. */ #define check(EXPR) check_func ((EXPR), __LINE__) -/* Prints a message about memory exhaustion and exits with a - failure code. */ -static void -xalloc_die (void) -{ - printf ("virtual memory exhausted\n"); - exit (EXIT_FAILURE); -} - -static void *xmalloc (size_t n) MALLOC_LIKE; -static void *xnmalloc (size_t n, size_t m) MALLOC_LIKE; -static void *xmemdup (const void *p, size_t n) MALLOC_LIKE; - -/* Allocates and returns N bytes of memory. */ -static void * -xmalloc (size_t n) -{ - if (n != 0) - { - void *p = malloc (n); - if (p == NULL) - xalloc_die (); - - return p; - } - else - return NULL; -} - -static void * -xmemdup (const void *p, size_t n) -{ - void *q = xmalloc (n); - memcpy (q, p, n); - return q; -} - -/* Clone STRING. */ -static char * -xstrdup (const char *string) -{ - return xmemdup (string, strlen (string) + 1); -} - -/* Allocates and returns N * M bytes of memory. */ -static void * -xnmalloc (size_t n, size_t m) -{ - if ((size_t) -1 / m <= n) - xalloc_die (); - return xmalloc (n * m); -} /* Support routines. */