Makefile: add benchmarks to top-level
[model-checker.git] / mymemory.cc
index 387d6de02365803b8dd33675539918b8d825ebbc..5922a32d19f63491d556a275cb2d25be5bf510da 100644 (file)
@@ -73,19 +73,31 @@ void *model_malloc(size_t size)
 /** @brief Snapshotting malloc, for use by model-checker (not user progs) */
 void * snapshot_malloc(size_t size)
 {
-       return malloc(size);
+       void *tmp = mspace_malloc(model_snapshot_space, size);
+       ASSERT(tmp);
+       return tmp;
 }
 
 /** @brief Snapshotting calloc, for use by model-checker (not user progs) */
 void * snapshot_calloc(size_t count, size_t size)
 {
-       return calloc(count, size);
+       void *tmp = mspace_calloc(model_snapshot_space, count, size);
+       ASSERT(tmp);
+       return tmp;
+}
+
+/** @brief Snapshotting realloc, for use by model-checker (not user progs) */
+void *snapshot_realloc(void *ptr, size_t size)
+{
+       void *tmp = mspace_realloc(model_snapshot_space, ptr, size);
+       ASSERT(tmp);
+       return tmp;
 }
 
 /** @brief Snapshotting free, for use by model-checker (not user progs) */
 void snapshot_free(void *ptr)
 {
-       free(ptr);
+       mspace_free(model_snapshot_space, ptr);
 }
 
 /** Non-snapshotting free for our use. */
@@ -137,9 +149,7 @@ mspace model_snapshot_space = NULL;
 
 #if USE_MPROTECT_SNAPSHOT
 
-/** @brief Global mspace reference for the user's snapshotting heap
- *  @todo use this ONLY for user's allocations, not for internal snapshotting
- *  state */
+/** @brief Global mspace reference for the user's snapshotting heap */
 mspace user_snapshot_space = NULL;
 
 /** Check whether this is bootstrapped memory that we should not free */