Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/malloc_wrapper.cc')
-rw-r--r--winsup/cygwin/malloc_wrapper.cc39
1 files changed, 23 insertions, 16 deletions
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 7e17fd9ec..2e10cddc5 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -13,6 +13,9 @@ details. */
#include "winsup.h"
#include <stdlib.h>
+#include <assert.h>
+#include "cygheap.h"
+#include "heap.h"
#include "sync.h"
/* we provide these stubs to call into a user's
@@ -60,6 +63,8 @@ extern "C" void
_free_r (struct _reent *, void *p)
{
export_malloc_called = 1;
+ assert (!incygheap (p));
+ assert (inheap (p));
free (p);
}
#undef free
@@ -68,6 +73,8 @@ extern "C" void *
_realloc_r (struct _reent *, void *p, size_t size)
{
export_malloc_called = 1;
+ assert (!incygheap (p));
+ assert (inheap (p));
return realloc (p, size);
}
#undef realloc
@@ -122,6 +129,22 @@ calloc (size_t nmemb, size_t size)
res = user_data->calloc (nmemb, size);
return res;
}
+
+extern "C" char *
+strdup (const char *s)
+{
+ char *p;
+ size_t len = strlen (s) + 1;
+ if ((p = (char *) malloc (len)) != NULL)
+ memcpy (p, s, len);
+ return p;
+}
+
+extern "C" char *
+_strdup_r (struct _reent *, const char *s)
+{
+ return strdup (s);
+}
#endif
/* These routines are used by the application if it
@@ -178,22 +201,6 @@ export_calloc (size_t nmemb, size_t size)
return res;
}
-extern "C" char *
-strdup (const char *s)
-{
- char *p;
- size_t len = strlen (s) + 1;
- if ((p = (char *) malloc (len)) != NULL)
- memcpy (p, s, len);
- return p;
-}
-
-extern "C" char *
-_strdup_r (struct _reent *, const char *s)
-{
- return strdup (s);
-}
-
/* We use a critical section to lock access to the malloc data
structures. This permits malloc to be called from different
threads. Note that it does not make malloc reentrant, and it does