X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=mymemory.cc;h=6ea6b92927c4ddebabe5b690b13800667a70fd08;hp=f296048406abd251c0e19447aed4090ecb5a63a1;hb=7966c737f2a88e5e1a56817eb9f6fdaead3eca92;hpb=99928ab8d61239d499f5bf45ae9a2b41595350f8 diff --git a/mymemory.cc b/mymemory.cc index f2960484..6ea6b929 100644 --- a/mymemory.cc +++ b/mymemory.cc @@ -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. */ @@ -123,7 +135,7 @@ void * HandleEarlyAllocationRequest(size_t sz) sz = (sz + 7) & ~7; if (sz > (BOOTSTRAPBYTES-offset)) { - printf("OUT OF BOOTSTRAP MEMORY\n"); + model_print("OUT OF BOOTSTRAP MEMORY\n"); exit(EXIT_FAILURE); } @@ -132,11 +144,12 @@ void * HandleEarlyAllocationRequest(size_t sz) return pointer; } +/** @brief Global mspace reference for the model-checker's snapshotting heap */ +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 */