summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/malloc_wrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/malloc_wrapper.cc')
-rw-r--r--winsup/cygwin/malloc_wrapper.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 48a82beca..86b74d564 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -84,6 +84,17 @@ realloc (void *p, size_t size)
return res;
}
+/* BSD extension: Same as realloc, just if it fails to allocate new memory,
+ it frees the incoming pointer. */
+extern "C" void *
+reallocf (void *p, size_t size)
+{
+ void *res = realloc (p, size);
+ if (!res && p)
+ free (p);
+ return res;
+}
+
extern "C" void *
calloc (size_t nmemb, size_t size)
{