#include "basetype.h"Go to the source code of this file.
Defines | |
| #define | geRam_Allocate(size) _geRam_DebugAllocate(size, __FILE__, __LINE__) |
| #define | geRam_Free(xxx) geRam_Free_(xxx) ,(xxx)=NULL, StupidUnusedPointer=(xxx) |
| #define | geRam_Realloc(ptr, newsize) _geRam_DebugRealloc(ptr, newsize, __FILE__, __LINE__) |
| #define | GE_RAM_ALLOCATE_STRUCT(type) (type *)geRam_Allocate (sizeof (type)) |
| #define | GE_RAM_ALLOCATE_ARRAY(type, count) (type *)geRam_Allocate (sizeof (type) * (count)) |
| #define | GE_RAM_REALLOC_ARRAY(ptr, type, count) (type *)geRam_Realloc( (ptr), sizeof(type) * (count) );{type *XX=(ptr);} |
Typedefs | |
| typedef int(* | geRam_CriticalCallbackFunction )(void) |
Functions | |
| GENESISAPI geRam_CriticalCallbackFunction | geRam_SetCriticalCallback (geRam_CriticalCallbackFunction callback) |
| GENESISAPI int | geRam_EnableCriticalCallback (int add) |
| GENESISAPI void * | _geRam_DebugAllocate (uint32 size, const char *pFile, int line) |
| GENESISAPI void | geRam_Free_ (void *ptr) |
| GENESISAPI void * | _geRam_DebugRealloc (void *ptr, uint32 size, const char *pFile, int line) |
| GENESISAPI void | geRam_ReportAllocations (void) |
| GENESISAPI void | geRam_AddAllocation (int n, uint32 size) |
| GENESISAPI void * | geRam_AllocateClear (uint32 size) |
| geBoolean | geRam_IsValidPtr (void *ptr) |
Variables | |
| void * | StupidUnusedPointer |
| int32 | geRam_CurrentlyUsed |
| int32 | geRam_NumberOfAllocations |
| int32 | geRam_MaximumUsed |
| int32 | geRam_MaximumNumberOfAllocations |
|
|
|
|
Definition at line 126 of file RAM.H. Referenced by geActor_AddMotion(), geBody_AddBone(), geBody_AddMaterial(), geBody_AddNormal(), geBody_AddSkinVertex(), geBody_AddToFaces(), gePose_AddJoint(), geWorld_AddActor(), and geWorld_AddSprite(). |
|
|
|
|
|
Definition at line 31 of file RAM.H. Referenced by geRam_SetCriticalCallback(). |
|
||||||||||||||||
|
Definition at line 247 of file Ram.c. References EXTRA_SIZE, GENESISAPI, geRam_CurrentlyUsed, geRam_DoCriticalCallback(), geRam_MaximumNumberOfAllocations, geRam_MaximumUsed, geRam_NumberOfAllocations, geRam_SetupBlock(), HEADER_SIZE, INITIALIZE_MEMORY, and NULL. Referenced by _geRam_DebugRealloc().
00248 {
00249 char *p;
00250
00251 do
00252 {
00253 p = (char*)_malloc_dbg (size + EXTRA_SIZE, _NORMAL_BLOCK, pFile, line);
00254 } while ((p == NULL) && geRam_DoCriticalCallback ());
00255
00256 if (p == NULL)
00257 {
00258 return NULL;
00259 }
00260
00261 // setup size stamps and memory overwrite checks
00262 geRam_SetupBlock (p, size, INITIALIZE_MEMORY);
00263
00264 // and update the allocations stuff
00265 geRam_NumberOfAllocations++;
00266 geRam_CurrentlyUsed += size;
00267
00268 if (geRam_NumberOfAllocations > geRam_MaximumNumberOfAllocations)
00269 {
00270 geRam_MaximumNumberOfAllocations = geRam_NumberOfAllocations;
00271 }
00272 if (geRam_CurrentlyUsed > geRam_MaximumUsed)
00273 {
00274 geRam_MaximumUsed = geRam_CurrentlyUsed;
00275 }
00276
00277 return p+HEADER_SIZE;
00278 }
|
|
||||||||||||||||||||
|
Definition at line 384 of file Ram.c. References _geRam_DebugAllocate(), DONT_INITIALIZE, EXTRA_SIZE, GENESISAPI, geRam_CurrentlyUsed, geRam_DoCriticalCallback(), geRam_Free, geRam_MaximumUsed, geRam_SetupBlock(), HEADER_SIZE, NULL, ram_verify_block(), and uint32.
00385 {
00386 char *p;
00387 char * NewPtr;
00388 uint32 size;
00389
00390 // if realloc is called with NULL, just treat it like an alloc
00391 if (ptr == NULL)
00392 {
00393 return _geRam_DebugAllocate(newsize, pFile, line);
00394 }
00395
00396 // verify the block
00397 p = ram_verify_block (ptr);
00398 if (p == NULL)
00399 {
00400 return NULL;
00401 }
00402
00403 // if newsize is NULL, then it's a free and return NULL
00404 if (newsize == 0)
00405 {
00406 geRam_Free (ptr);
00407 return NULL;
00408 }
00409
00410 // gotta get the size before I realloc it...
00411 size = *((uint32 *)p);
00412
00413 do
00414 {
00415 NewPtr = (char *)_realloc_dbg(p, newsize+EXTRA_SIZE, _NORMAL_BLOCK, pFile, line);
00416 } while ((NewPtr == NULL) && geRam_DoCriticalCallback ());
00417
00418 // if allocation failed, return NULL...
00419 if (NewPtr == NULL)
00420 {
00421 return NULL;
00422 }
00423
00424 geRam_SetupBlock (NewPtr, newsize, DONT_INITIALIZE);
00425
00426 geRam_CurrentlyUsed += (newsize - size);
00427 if (geRam_CurrentlyUsed > geRam_MaximumUsed)
00428 {
00429 geRam_MaximumUsed = geRam_CurrentlyUsed;
00430 }
00431 assert ((geRam_CurrentlyUsed >= 0) && "free()d more ram than you allocated!");
00432
00433 return NewPtr + HEADER_SIZE;
00434 }
|
|
||||||||||||
|
Definition at line 503 of file Ram.c. References GENESISAPI, geRam_CurrentlyUsed, geRam_MaximumNumberOfAllocations, geRam_MaximumUsed, and geRam_NumberOfAllocations.
00504 {
00505 // and update the allocations stuff
00506 geRam_NumberOfAllocations += n;
00507 geRam_CurrentlyUsed += size;
00508
00509 if (geRam_NumberOfAllocations > geRam_MaximumNumberOfAllocations)
00510 {
00511 geRam_MaximumNumberOfAllocations = geRam_NumberOfAllocations;
00512 }
00513 if (geRam_CurrentlyUsed > geRam_MaximumUsed)
00514 {
00515 geRam_MaximumUsed = geRam_CurrentlyUsed;
00516 }
00517 }
|
|
|
Definition at line 107 of file Ram.c. References GENESISAPI, geRam_Allocate, and uint32. Referenced by createPaletteFast(), createPaletteGoodSub(), and Particles_Create().
00108 {
00109 void * mem;
00110 size = (size + 3)&(~(uint32)3);
00111 mem = geRam_Allocate(size);
00112 if ( mem )
00113 {
00114 memset(mem,0,size);
00115 }
00116 return mem;
00117 }
|
|
|
Definition at line 64 of file Ram.c. References GENESISAPI, and geRam_CriticalAllocationCount.
00065 {
00066 geRam_CriticalAllocationCount += add;
00067 return geRam_CriticalAllocationCount;
00068 }
|
|
|
Definition at line 353 of file Ram.c. References EXTRA_SIZE, FreeFillerByte, GENESISAPI, geRam_CurrentlyUsed, geRam_NumberOfAllocations, NULL, ram_verify_block(), and uint32.
00354 {
00355 char *p;
00356 uint32 size;
00357
00358 // make sure it's a valid block...
00359 p = ram_verify_block (ptr);
00360 if (p == NULL)
00361 {
00362 return;
00363 }
00364
00365 // gotta get the size before you free it
00366 size = *((uint32 *)p);
00367
00368 // fill it with trash...
00369 memset (p, FreeFillerByte, size+EXTRA_SIZE);
00370
00371 // free the memory
00372 free (p);
00373
00374 // update allocations
00375 geRam_NumberOfAllocations--;
00376 assert ((geRam_NumberOfAllocations >= 0) && "free()d more ram than you allocated!");
00377
00378 geRam_CurrentlyUsed -= size;
00379 assert ((geRam_CurrentlyUsed >= 0) && "free()d more ram than you allocated!");
00380 }
|
|
|
Definition at line 523 of file Ram.c. References GE_FALSE, GE_TRUE, geBoolean, HEADER_SIZE, MemStamp, MemStampSize, NULL, SizeSize, and uint32. Referenced by MemBlock_IsValid().
00524 {
00525 char * p = ptr;
00526 uint32 size;
00527
00528 if (p == NULL) return GE_FALSE;
00529
00530 // make p point to the beginning of the block
00531 p -= HEADER_SIZE;
00532
00533 // get size from block
00534 size = *((uint32 *)p);
00535
00536 // check stamp at front
00537 if (memcmp (p+SizeSize, MemStamp, MemStampSize) != 0)
00538 {
00539 return GE_FALSE;
00540 }
00541
00542 // and at back
00543 if (memcmp (p+HEADER_SIZE+size, MemStamp, MemStampSize) != 0)
00544 {
00545 return GE_FALSE;
00546 }
00547
00548 return GE_TRUE;
00549 }
|
|
|
Definition at line 494 of file Ram.c. References GENESISAPI.
00495 {
00496 _CrtDumpMemoryLeaks();
00497 }
|
|
|
Definition at line 76 of file Ram.c. References geRam_CriticalCallback, and geRam_CriticalCallbackFunction.
00079 {
00080 geRam_CriticalCallbackFunction OldCallback;
00081
00082 OldCallback = geRam_CriticalCallback;
00083 geRam_CriticalCallback = critical_callback;
00084 return OldCallback;
00085 }
|
|
|
Definition at line 109 of file RAM.H. Referenced by _geRam_DebugAllocate(), _geRam_DebugRealloc(), geRam_AddAllocation(), and geRam_Free_(). |
|
|
Definition at line 112 of file RAM.H. Referenced by _geRam_DebugAllocate(), and geRam_AddAllocation(). |
|
|
Definition at line 111 of file RAM.H. Referenced by _geRam_DebugAllocate(), _geRam_DebugRealloc(), and geRam_AddAllocation(). |
|
|
Definition at line 110 of file RAM.H. Referenced by _geRam_DebugAllocate(), geRam_AddAllocation(), and geRam_Free_(). |
|
|
|
1.3.2