From: Jim Meyering Date: Sat, 25 Oct 1997 04:38:58 +0000 (+0000) Subject: Include xalloc.h. X-Git-Tag: TEXTUTILS-1_22c~184 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0b56b516a19b8e3a97380b837005f41fa6dc390;p=thirdparty%2Fcoreutils.git Include xalloc.h. (xmalloc): Remove function. (xrealloc): Remove function. (main): Set xalloc_fail_func to cleanup. --- diff --git a/src/csplit.c b/src/csplit.c index f7aa9fdedb..b0c6d65156 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -49,6 +49,7 @@ #include "system.h" #include "error.h" #include "xstrtoul.h" +#include "xalloc.h" #ifdef STDC_HEADERS # include @@ -276,46 +277,6 @@ interrupt_handler (int sig) kill (getpid (), sig); } -/* Allocate N bytes of memory dynamically, with error checking. */ - -static char * -xmalloc (unsigned int n) -{ - char *p; - - p = malloc (n); - if (p == NULL) - { - error (0, 0, _("virtual memory exhausted")); - cleanup_fatal (); - } - return p; -} - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. - If P is NULL, run xmalloc. - If N is 0, run free and return NULL. */ - -static char * -xrealloc (char *p, unsigned int n) -{ - if (p == NULL) - return xmalloc (n); - if (n == 0) - { - free (p); - return 0; - } - p = realloc (p, n); - if (p == NULL) - { - error (0, 0, _("virtual memory exhausted")); - cleanup_fatal (); - } - return p; -} - /* Keep track of NUM chars of a partial line in buffer START. These chars will be retrieved later when another large buffer is read. It is not necessary to create a new buffer for these chars; instead, @@ -1442,6 +1403,9 @@ main (int argc, char **argv) remove_files = TRUE; prefix = DEFAULT_PREFIX; + /* Change the way xmalloc and xrealloc fail. */ + xalloc_fail_func = cleanup; + #ifdef SA_INTERRUPT newact.sa_handler = interrupt_handler; sigemptyset (&newact.sa_mask);