From a0b56b516a19b8e3a97380b837005f41fa6dc390 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 25 Oct 1997 04:38:58 +0000 Subject: Include xalloc.h. (xmalloc): Remove function. (xrealloc): Remove function. (main): Set xalloc_fail_func to cleanup. --- src/csplit.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/src/csplit.c b/src/csplit.c index f7aa9fded..b0c6d6515 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); -- cgit v1.2.3-70-g09d2