summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-10-25 04:43:10 +0000
committerJim Meyering <jim@meyering.net>1997-10-25 04:43:10 +0000
commit0927513b1648b948224eebc4f1d90eda5ba9949e (patch)
tree5164da7307ebb07864024a31a74283f1620e1cb3 /src/sort.c
parent0873056df711946b57eb4bab34476698b2e03b1e (diff)
downloadcoreutils-0927513b1648b948224eebc4f1d90eda5ba9949e.tar.xz
Include xalloc.h.
(xmalloc): Remove function. (xrealloc): Remove function. (main): Set xalloc_fail_func to cleanup. Set xmalloc_exit_failure SORT_FAILURE.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c47
1 files changed, 5 insertions, 42 deletions
diff --git a/src/sort.c b/src/sort.c
index 1312c1954..b68b136ce 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -37,6 +37,7 @@
#include "long-options.h"
#include "error.h"
#include "xstrtod.h"
+#include "xalloc.h"
#ifdef ENABLE_NLS
# include <langinfo.h>
@@ -347,48 +348,6 @@ cleanup (void)
unlink (node->name);
}
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-static char *
-xmalloc (unsigned int n)
-{
- char *p;
-
- p = malloc (n);
- if (p == 0)
- {
- error (0, 0, _("virtual memory exhausted"));
- cleanup ();
- exit (SORT_FAILURE);
- }
- 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 == 0)
- return xmalloc (n);
- if (n == 0)
- {
- free (p);
- return 0;
- }
- p = realloc (p, n);
- if (p == 0)
- {
- error (0, 0, _("virtual memory exhausted"));
- cleanup ();
- exit (SORT_FAILURE);
- }
- return p;
-}
-
static FILE *
xtmpfopen (const char *file)
{
@@ -2554,6 +2513,10 @@ main (int argc, char **argv)
if (temp_file_prefix == NULL)
temp_file_prefix = DEFAULT_TMPDIR;
+ /* Change the way xmalloc and xrealloc fail. */
+ xmalloc_exit_failure = SORT_FAILURE;
+ xalloc_fail_func = cleanup;
+
#ifdef SA_INTERRUPT
newact.sa_handler = sighandler;
sigemptyset (&newact.sa_mask);