changeset 1088:1ae95221563d

(xalloc_fail): Renamed from fixup_null_alloc. (xcalloc): #ifdef-out unused function. (xrealloc): Remove code to work around deficient versions of realloc. Now we have an autoconf-enabled replacement version. (xmalloc): Remove code to work around deficient versions of malloc. Now we have an autoconf-enabled replacement version.
author Jim Meyering <jim@meyering.net>
date Mon, 03 Nov 1997 05:25:44 +0000
parents 5043c5fa8ccb
children d02ee0800a52
files lib/xmalloc.c
diffstat 1 files changed, 24 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -71,22 +71,12 @@
 void error ();
 #endif
 
-static void *
-fixup_null_alloc (n)
-     size_t n;
+static void
+xalloc_fail ()
 {
-  void *p;
-
-  p = 0;
-  if (n == 0)
-    p = malloc ((size_t) 1);
-  if (p == 0)
-    {
-      if (xalloc_fail_func)
-	(*xalloc_fail_func) ();
-      error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted);
-    }
-  return p;
+  if (xalloc_fail_func)
+    (*xalloc_fail_func) ();
+  error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted);
 }
 
 /* Allocate N bytes of memory dynamically, with error checking.  */
@@ -99,10 +89,27 @@
 
   p = malloc (n);
   if (p == 0)
-    p = fixup_null_alloc (n);
+    xalloc_fail ();
   return p;
 }
 
+/* Change the size of an allocated block of memory P to N bytes,
+   with error checking.
+   If P is NULL, run xmalloc.  */
+
+void *
+xrealloc (p, n)
+     void *p;
+     size_t n;
+{
+  p = realloc (p, n);
+  if (p == 0)
+    xalloc_fail ();
+  return p;
+}
+
+#ifdef NOT_USED
+
 /* Allocate memory for N elements of S bytes, with error checking.  */
 
 void *
@@ -117,19 +124,4 @@
   return p;
 }
 
-/* Change the size of an allocated block of memory P to N bytes,
-   with error checking.
-   If P is NULL, run xmalloc.  */
-
-void *
-xrealloc (p, n)
-     void *p;
-     size_t n;
-{
-  if (p == 0)
-    return xmalloc (n);
-  p = realloc (p, n);
-  if (p == 0)
-    p = fixup_null_alloc (n);
-  return p;
-}
+#endif /* NOT_USED */