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. */
p = malloc (n);
if (p == 0)
- p = fixup_null_alloc (n);
- return p;
-}
-
-/* Allocate memory for N elements of S bytes, with error checking. */
-
-void *
-xcalloc (n, s)
- size_t n, s;
-{
- void *p;
-
- p = calloc (n, s);
- if (p == 0)
- p = fixup_null_alloc (n);
+ xalloc_fail ();
return p;
}
void *p;
size_t n;
{
- if (p == 0)
- return xmalloc (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 *
+xcalloc (n, s)
+ size_t n, s;
+{
+ void *p;
+
+ p = calloc (n, s);
if (p == 0)
p = fixup_null_alloc (n);
return p;
}
+
+#endif /* NOT_USED */