projects
/
c11tester.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove plugins
[c11tester.git]
/
mymemory.cc
diff --git
a/mymemory.cc
b/mymemory.cc
index 4182e094e5251c1a8efedbe8a92c232c012f13f3..e8ec08050f5d8e5389c01e136fe1c0a27f374f13 100644
(file)
--- a/
mymemory.cc
+++ b/
mymemory.cc
@@
-16,6
+16,7
@@
size_t allocatedReqs[REQUESTS_BEFORE_ALLOC] = { 0 };
int nextRequest = 0;
int howManyFreed = 0;
size_t allocatedReqs[REQUESTS_BEFORE_ALLOC] = { 0 };
int nextRequest = 0;
int howManyFreed = 0;
+int switch_alloc = 0;
#if !USE_MPROTECT_SNAPSHOT
static mspace sStaticSpace = NULL;
#endif
#if !USE_MPROTECT_SNAPSHOT
static mspace sStaticSpace = NULL;
#endif
@@
-179,6
+180,9
@@
static void * user_malloc(size_t size)
void *malloc(size_t size)
{
if (user_snapshot_space) {
void *malloc(size_t size)
{
if (user_snapshot_space) {
+ if (switch_alloc) {
+ return model_malloc(size);
+ }
/* Only perform user allocations from user context */
ASSERT(!model || thread_current());
return user_malloc(size);
/* Only perform user allocations from user context */
ASSERT(!model || thread_current());
return user_malloc(size);
@@
-189,8
+193,12
@@
void *malloc(size_t size)
/** @brief Snapshotting free implementation for user programs */
void free(void * ptr)
{
/** @brief Snapshotting free implementation for user programs */
void free(void * ptr)
{
- if (!DontFree(ptr))
+ if (!DontFree(ptr)) {
+ if (switch_alloc) {
+ return model_free(ptr);
+ }
mspace_free(user_snapshot_space, ptr);
mspace_free(user_snapshot_space, ptr);
+ }
}
/** @brief Snapshotting realloc implementation for user programs */
}
/** @brief Snapshotting realloc implementation for user programs */