X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fstringi-map-test.c;h=a78fd56557f53a46be68ac9a32a346fe1f377acd;hb=23d437dff0fd93d652ee3cf2c970465ea0037be3;hp=3ae027fb36db78b5afaf6b28890810a1da26847b;hpb=6f3865480503c571963d8a2d1af858a4d72d4e88;p=pspp diff --git a/tests/libpspp/stringi-map-test.c b/tests/libpspp/stringi-map-test.c index 3ae027fb36..a78fd56557 100644 --- a/tests/libpspp/stringi-map-test.c +++ b/tests/libpspp/stringi-map-test.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010, 2012, 2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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. */ @@ -145,7 +93,7 @@ get_string (int idx) if (*s == NULL) { *s = xmalloc (16); - str_format_26adic (idx + 1, *s, 16); + str_format_26adic (idx + 1, true, *s, 16); } return *s; }