[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] xmalloc: revert yesterday's regression
From: |
Eric Blake |
Subject: |
[PATCH] xmalloc: revert yesterday's regression |
Date: |
Fri, 25 Mar 2011 10:50:39 -0600 |
* lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to
realloc's underlying behavior (allowing allocation of zero-size
objects, especially if malloc-gnu is also in use).
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 7 +++++++
lib/xmalloc.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eba7d4e..c6c9690 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-25 Eric Blake <address@hidden>
+
+ xmalloc: revert yesterday's regression
+ * lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to
+ realloc's underlying behavior (allowing allocation of zero-size
+ objects, especially if malloc-gnu is also in use).
+
2011-03-25 Reuben Thomas <address@hidden>
maint.mk: add missing version to VC-tag
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 4589e7d..08c30fb 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -52,7 +52,7 @@ xmalloc (size_t n)
void *
xrealloc (void *p, size_t n)
{
- if (!n)
+ if (!n && p)
{
/* The GNU and C99 realloc behaviors disagree here. Act like
GNU, even if the underlying realloc is C99. */
@@ -61,7 +61,7 @@ xrealloc (void *p, size_t n)
}
p = realloc (p, n);
- if (!p)
+ if (!p && n)
xalloc_die ();
return p;
}
--
1.7.4
- Re: proper realloc(p,0) behavior?, (continued)
- Re: proper realloc(p,0) behavior?, Paul Eggert, 2011/03/24
- Re: proper realloc(p,0) behavior?, Jim Meyering, 2011/03/24
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/24
- Re: proper realloc(p,0) behavior?, Paul Eggert, 2011/03/24
- Re: proper realloc(p,0) behavior?, Paolo Bonzini, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
- Re: proper realloc(p,0) behavior?, Paolo Bonzini, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
- Re: proper realloc(p,0) behavior?, Paul Eggert, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
- [PATCH] xmalloc: revert yesterday's regression,
Eric Blake <=
- Re: proper realloc(p,0) behavior?, Paul Eggert, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
[PATCH] realloc: document portability problem, Eric Blake, 2011/03/24
Re: proper realloc(p,0) behavior?, Bruno Haible, 2011/03/24
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
- Re: proper realloc(p,0) behavior?, Bruno Haible, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
- Re: proper realloc(p,0) behavior?, Paul Eggert, 2011/03/25
- Re: proper realloc(p,0) behavior?, Eric Blake, 2011/03/25
Re: proper realloc(p,0) behavior?, Bruno Haible, 2011/03/24