void *MYMALLOC(size_t size) {
#if USE_MPROTECT_SNAPSHOT
static void *(*mallocp)(size_t size);
char *error;
void *ptr;
void *MYMALLOC(size_t size) {
#if USE_MPROTECT_SNAPSHOT
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");
/* get address of libc malloc */
if (!mallocp) {
mallocp = ( void * ( * )( size_t ) )dlsym(RTLD_NEXT, "malloc");
- sStaticSpace = create_mspace_with_base( ( void * )( sTheRecord->mSharedMemoryBase ), SHARED_MEMORY_DEFAULT -sizeof( struct Snapshot ), 1 );
+ sStaticSpace = create_mspace_with_base( ( void * )( snapshotrecord->mSharedMemoryBase ), SHARED_MEMORY_DEFAULT -sizeof( struct SnapShot ), 1 );
/** Adding the fix for not able to allocate through a reimplemented calloc at the beginning before instantiating our allocator
A bit circumspect about adding an sbrk. linux docs say to avoid using it... */
/** Adding the fix for not able to allocate through a reimplemented calloc at the beginning before instantiating our allocator
A bit circumspect about adding an sbrk. linux docs say to avoid using it... */
bool DontFree( void * ptr ){
if( howManyFreed == nextRequest ) return false; //a minor optimization to reduce the number of instructions executed on each free call....
if( NULL == ptr ) return true;
bool DontFree( void * ptr ){
if( howManyFreed == nextRequest ) return false; //a minor optimization to reduce the number of instructions executed on each free call....
if( NULL == ptr ) return true;
void *malloc( size_t size ) {
void * earlyReq = HandleEarlyAllocationRequest( size );
if( earlyReq ) return earlyReq;
void *malloc( size_t size ) {
void * earlyReq = HandleEarlyAllocationRequest( size );
if( earlyReq ) return earlyReq;
void free( void * ptr ){
if( DontFree( ptr ) ) return;
mspace_free( mySpace, ptr );
}
/** Snapshotting realloc implementation for user programs. */
void free( void * ptr ){
if( DontFree( ptr ) ) return;
mspace_free( mySpace, ptr );
}
/** Snapshotting realloc implementation for user programs. */
void *realloc( void *ptr, size_t size ){
return mspace_realloc( mySpace, ptr, size );
}
/** Snapshotting calloc implementation for user programs. */
void *realloc( void *ptr, size_t size ){
return mspace_realloc( mySpace, ptr, size );
}
/** Snapshotting calloc implementation for user programs. */
void * calloc( size_t num, size_t size ){
void * earlyReq = HandleEarlyAllocationRequest( size * num );
if( earlyReq ) {
void * calloc( size_t num, size_t size ){
void * earlyReq = HandleEarlyAllocationRequest( size * num );
if( earlyReq ) {
void * operator new(size_t size) throw(std::bad_alloc) {
return malloc(size);
}
/** Snapshotting delete operator for user programs. */
void * operator new(size_t size) throw(std::bad_alloc) {
return malloc(size);
}
/** Snapshotting delete operator for user programs. */
void * operator new[](size_t size) throw(std::bad_alloc) {
return malloc(size);
}
/** Snapshotting delete[] operator for user programs. */
void * operator new[](size_t size) throw(std::bad_alloc) {
return malloc(size);
}
/** Snapshotting delete[] operator for user programs. */