This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] test-skeleton.c (xrealloc): Support realloc-as-free


If the requested size is zero, realloc returns NULL, but the
deallocation is still successful.

2016-06-23  Florian Weimer  <fweimer@redhat.com>

	* test-skeleton.c (xrealloc): Support deallocation with n == 0.

diff --git a/test-skeleton.c b/test-skeleton.c
index 0be4af1..243cd94 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -110,7 +110,7 @@ static void *
 xrealloc (void *p, size_t n)
 {
   p = realloc (p, n);
-  if (p == NULL)
+  if (p == NULL && n > 0)
     oom_error ("realloc", n);
   return p;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]