mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
test-skeleton.c (xrealloc): Support realloc-as-free
If the requested size is zero, realloc returns NULL, but the deallocation is still successful, unless the pointer is also NULL, when realloc behaves as malloc (0).
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2016-06-23 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* test-skeleton.c (xrealloc): Support deallocation with n == 0.
|
||||||
|
|
||||||
2016-06-23 Florian Weimer <fweimer@redhat.com>
|
2016-06-23 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
* test-skeleton.c (xmalloc, xcalloc, xrealloc): Mark as
|
* test-skeleton.c (xmalloc, xcalloc, xrealloc): Mark as
|
||||||
|
@@ -109,10 +109,10 @@ __attribute__ ((unused))
|
|||||||
static void *
|
static void *
|
||||||
xrealloc (void *p, size_t n)
|
xrealloc (void *p, size_t n)
|
||||||
{
|
{
|
||||||
p = realloc (p, n);
|
void *result = realloc (p, n);
|
||||||
if (p == NULL)
|
if (result == NULL && (n > 0 || p == NULL))
|
||||||
oom_error ("realloc", n);
|
oom_error ("realloc", n);
|
||||||
return p;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a message to standard output. Can be used in signal
|
/* Write a message to standard output. Can be used in signal
|
||||||
|
Reference in New Issue
Block a user