/* * HunkLength is forced to be a multiple of 4 */ MemPool * AllocPool (long HunkLength,long NumHunks,long AutoExtendNumItems) { MemPool * Ret; if ( (Ret = malloc(sizeof(MemPool))) == NULL ) return(NULL); Ret->HunkLength = PaddedSize(HunkLength); Ret->CurMemBlock = NULL; Ret->MemBlock = NULL; Ret->NumFreedHunks = 0; Ret->MaxNumFreedHunks = 16; Ret->AutoExtendNumItems = AutoExtendNumItems; Ret->NumItemsActive = 0; if ( (Ret->FreedHunks = malloc(Ret->MaxNumFreedHunks*sizeofpointer)) == NULL ) { free(Ret); return(NULL); } if ( ! ExtendPool(Ret,NumHunks) ) { free(Ret->FreedHunks); free(Ret); return(NULL); } return(Ret); }
/* Returns the total amount of memory which we need to get from the system in order to satisfy a caller request. This includes space for the struct plus markers and the caller's memory as well. */ size_t wxDebugContext::TotSize (const size_t reqSize) { return (PaddedSize (sizeof (wxMemStruct)) + PaddedSize (reqSize) + 2 * sizeof(wxMarkerType)); }
char * wxDebugContext::EndMarkerPos (const char * buf, const size_t size) { return CallerMemPos (buf) + PaddedSize (size); }
char * wxDebugContext::CallerMemPos (const char * buf) { return MidMarkerPos (buf) + PaddedSize (sizeof(wxMarkerType)); }
char * wxDebugContext::MidMarkerPos (const char * buf) { return StructPos (buf) + PaddedSize (sizeof (wxMemStruct)); }