]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include xalloc.h.
authorJim Meyering <jim@meyering.net>
Sat, 25 Oct 1997 04:38:58 +0000 (04:38 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 25 Oct 1997 04:38:58 +0000 (04:38 +0000)
(xmalloc): Remove function.
(xrealloc): Remove function.
(main): Set xalloc_fail_func to cleanup.

src/csplit.c

index f7aa9fdedbf3c7ffa3bc11bc97ac68130c520a0a..b0c6d6515668322cac31ed6b342d0a4b4d6d926b 100644 (file)
@@ -49,6 +49,7 @@
 #include "system.h"
 #include "error.h"
 #include "xstrtoul.h"
+#include "xalloc.h"
 
 #ifdef STDC_HEADERS
 # include <stdlib.h>
@@ -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);