summaryrefslogtreecommitdiff
path: root/lib/xmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xmalloc.c')
-rw-r--r--lib/xmalloc.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 74a8614..57e34b7 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -1,6 +1,6 @@
/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,11 +17,9 @@
#include <config.h>
-#if ! HAVE_INLINE
-# define static_inline
-#endif
+#define XALLOC_INLINE _GL_EXTERN_INLINE
+
#include "xalloc.h"
-#undef static_inline
#include <stdlib.h>
#include <string.h>
@@ -52,8 +50,16 @@ xmalloc (size_t n)
void *
xrealloc (void *p, size_t n)
{
+ if (!n && p)
+ {
+ /* The GNU and C99 realloc behaviors disagree here. Act like
+ GNU, even if the underlying realloc is C99. */
+ free (p);
+ return NULL;
+ }
+
p = realloc (p, n);
- if (!p && n != 0)
+ if (!p && n)
xalloc_die ();
return p;
}