]> granicus.if.org Git - gc/commitdiff
Recognize REDIRECT_MALLOC_IN_HEADER macro
authorIvan Maidanski <ivmai@mail.ru>
Sun, 25 Nov 2012 08:07:13 +0000 (12:07 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 11 May 2015 15:59:31 +0000 (18:59 +0300)
* include/private/gcconfig.h: Do not issue error on REDIRECT_MALLOC
and THREADS if REDIRECT_MALLOC_IN_HEADER defined.
* malloc.c (malloc, calloc, strdup, strndup, free): Do not define if
REDIRECT_MALLOC_IN_HEADER.
* mallocx.c (realloc): Likewise.

Conflicts:

    include/gc.h
    include/private/gcconfig.h
    malloc.c
    mallocx.c

include/private/gcconfig.h
malloc.c
mallocx.c

index 9dfcc064d9fbed73faf4565d42807cd89b50d00e..79978f2e4abcfbc19813a558000eb715aacbc3ec 100644 (file)
 # error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
 #endif
 
-#if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX)
+#if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) \
+     && !defined(REDIRECT_MALLOC_IN_HEADER)
 # error "REDIRECT_MALLOC with THREADS works at most on Linux."
 #endif
 
index a4dd437f49114dd021144aed6c792edca1ad042f..3e08657370062c8198172659b93091d911fef19f 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -351,6 +351,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(size_t lb)
 /* but it is admittedly quite ugly.                                     */
 # define GC_debug_malloc_replacement(lb) GC_debug_malloc(lb, GC_DBG_EXTRAS)
 
+#if !defined(REDIRECT_MALLOC_IN_HEADER)
 void * malloc(size_t lb)
 {
     /* It might help to manually inline the GC_malloc call here.        */
@@ -464,6 +465,8 @@ void * calloc(size_t n, size_t lb)
   }
 #endif /* !strndup */
 
+#endif /* !REDIRECT_MALLOC_IN_HEADER */
+
 #undef GC_debug_malloc_replacement
 
 #endif /* REDIRECT_MALLOC */
@@ -574,7 +577,7 @@ GC_API void GC_CALL GC_free(void * p)
 # define REDIRECT_FREE GC_free
 #endif
 
-#ifdef REDIRECT_FREE
+#if defined(REDIRECT_FREE) && !defined(REDIRECT_MALLOC_IN_HEADER)
   void free(void * p)
   {
 #   if defined(GC_LINUX_THREADS) && !defined(USE_PROC_FOR_LIBRARIES)
index c851fcb9eb8ae16cd7bcaeb25db8f79766c31541..d1928805d76eb2b78466c2b0ee6a72dd1f35f200 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -165,10 +165,12 @@ GC_API void * GC_CALL GC_realloc(void * p, size_t lb)
 # define GC_debug_realloc_replacement(p, lb) \
         GC_debug_realloc(p, lb, GC_DBG_EXTRAS)
 
-void * realloc(void * p, size_t lb)
-  {
-    return(REDIRECT_REALLOC(p, lb));
-  }
+# if !defined(REDIRECT_MALLOC_IN_HEADER)
+    void * realloc(void * p, size_t lb)
+    {
+      return(REDIRECT_REALLOC(p, lb));
+    }
+# endif
 
 # undef GC_debug_realloc_replacement
 # endif /* REDIRECT_REALLOC */