mymemory: kill system_malloc()
[c11tester.git] / mymemory.cc
index 7aec2dc81d549bcf0fe82951ee902723077b5cf0..cdfa37282870e6e1d1665be7cea00d856a0a2b42 100644 (file)
@@ -88,24 +88,6 @@ void snapshot_free(void *ptr)
        free(ptr);
 }
 
-void *system_malloc(size_t size)
-{
-       static void *(*mallocp)(size_t size);
-       char *error;
-       void *ptr;
-
-       /* get address of libc malloc */
-       if (!mallocp) {
-               mallocp = (void * (*)(size_t))dlsym(RTLD_NEXT, "malloc");
-               if ((error = dlerror()) != NULL) {
-                       fputs(error, stderr);
-                       exit(EXIT_FAILURE);
-               }
-       }
-       ptr = mallocp(size);
-       return ptr;
-}
-
 /** Non-snapshotting free for our use. */
 void model_free(void *ptr)
 {
@@ -127,9 +109,6 @@ void model_free(void *ptr)
 #endif
 }
 
-/** @brief Global mspace reference for the snapshotting heap */
-mspace snapshot_space = NULL;
-
 /** Bootstrap allocation.  Problem is that the dynamic linker calls
  *  require calloc to work and calloc requires the dynamic linker to
  *     work.  */
@@ -153,6 +132,11 @@ void * HandleEarlyAllocationRequest(size_t sz)
        return pointer;
 }
 
+#if USE_MPROTECT_SNAPSHOT
+
+/** @brief Global mspace reference for the snapshotting heap */
+mspace snapshot_space = NULL;
+
 /** Check whether this is bootstrapped memory that we should not free */
 static bool DontFree(void *ptr)
 {
@@ -222,3 +206,4 @@ void operator delete[](void *p, size_t size)
 {
        free(p);
 }
+#endif /* USE_MPROTECT_SNAPSHOT */