summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-10-25 04:38:58 +0000
committerJim Meyering <jim@meyering.net>1997-10-25 04:38:58 +0000
commita0b56b516a19b8e3a97380b837005f41fa6dc390 (patch)
tree206cf944670bf15661b3b05423b0af83df9b5614 /src
parent7dcae67d92955ce049330ec906445c574892ed06 (diff)
downloadcoreutils-a0b56b516a19b8e3a97380b837005f41fa6dc390.tar.xz
Include xalloc.h.
(xmalloc): Remove function. (xrealloc): Remove function. (main): Set xalloc_fail_func to cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/csplit.c44
1 files 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 <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);