}
/** @brief Global mspace reference for the snapshotting heap */
-mspace mySpace = NULL;
+mspace snapshot_space = NULL;
/** Bootstrap allocation. Problem is that the dynamic linker calls
* require calloc to work and calloc requires the dynamic linker to
/** @brief Snapshotting malloc implementation for user programs */
void *malloc(size_t size)
{
- if (mySpace) {
- void *tmp = mspace_malloc(mySpace, size);
+ if (snapshot_space) {
+ void *tmp = mspace_malloc(snapshot_space, size);
ASSERT(tmp);
return tmp;
} else
void free(void * ptr)
{
if (!DontFree(ptr))
- mspace_free(mySpace, ptr);
+ mspace_free(snapshot_space, ptr);
}
/** @brief Snapshotting realloc implementation for user programs */
void *realloc(void *ptr, size_t size)
{
- void *tmp = mspace_realloc(mySpace, ptr, size);
+ void *tmp = mspace_realloc(snapshot_space, ptr, size);
ASSERT(tmp);
return tmp;
}
/** @brief Snapshotting calloc implementation for user programs */
void * calloc(size_t num, size_t size)
{
- if (mySpace) {
- void *tmp = mspace_calloc(mySpace, num, size);
+ if (snapshot_space) {
+ void *tmp = mspace_calloc(snapshot_space, num, size);
ASSERT(tmp);
return tmp;
} else {
extern void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
extern mspace create_mspace_with_base(void* base, size_t capacity, int locked);
extern mspace create_mspace(size_t capacity, int locked);
-extern mspace mySpace;
+
+/** @brief mspace for the snapshotting heap */
+extern mspace snapshot_space;
#ifdef __cplusplus
}; /* end of extern "C" */
#endif
void *basemySpace = model_malloc((numheappages+1)*PAGESIZE);
void * pagealignedbase=PageAlignAddressUpward(basemySpace);
- mySpace = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 );
+ snapshot_space = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 );
addMemoryRegionToSnapShot(pagealignedbase, numheappages);
entryPoint();
}
unsigned int numheappages, VoidFuncPtr entryPoint) {
void *basemySpace = system_malloc((numheappages+1)*PAGESIZE);
void * pagealignedbase=PageAlignAddressUpward(basemySpace);
- mySpace = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 );
+ snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
if (!snapshotrecord)
createSharedMemory();