|
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
memory.h
Go to the documentation of this file.
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36 #define ASSIGN(pointerstarstar, voidstarfunction) (*(pointerstarstar) = docast(*(pointerstarstar), (voidstarfunction)))
71 #define BMSreallocMemoryArray(ptr,num) ASSIGN((ptr), BMSreallocMemory_call( *(ptr), (num)*sizeof(**(ptr)), \
73 #define BMSallocMemoryArrayCPP(num,size) BMSallocMemory_call( (size_t)((num)*(size)), __FILE__, __LINE__ )
74 #define BMSallocClearMemoryArray(ptr,num) ASSIGN((ptr), BMSallocClearMemory_call((size_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ ))
89 : ( ASSIGN((ptr), BMSallocClearMemory_call((size_t)(num), sizeof(**(ptr)), __FILE__, __LINE__ )) ) )
92 #define BMSallocMemory(ptr) ASSIGN((ptr), BMSallocMemory_call( sizeof(**(ptr)), __FILE__, __LINE__ ))
93 #define BMSallocMemorySize(ptr,size) ASSIGN((ptr), BMSallocMemory_call( (size_t)(size), __FILE__, __LINE__ ))
95 #define BMSreallocMemorySize(ptr,size) ASSIGN((ptr), BMSreallocMemory_call( *(ptr), (size_t)(size), \
101 #define BMScopyMemory(ptr, source) BMScopyMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
102 #define BMScopyMemoryArray(ptr, source, num) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (num)*sizeof(*(ptr)) )
103 #define BMScopyMemorySize(ptr, source, size) BMScopyMemory_call( (void*)(ptr), (const void*)(source), (size_t)(size) )
105 #define BMSmoveMemory(ptr, source) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), sizeof(*(ptr)) )
106 #define BMSmoveMemoryArray(ptr, source, num) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (num) * sizeof(*(ptr)) )
107 #define BMSmoveMemorySize(ptr, source, size) BMSmoveMemory_call( (void*)(ptr), (const void*)(source), (size_t)(size) )
109 #define BMSduplicateMemory(ptr, source) ASSIGN((ptr), BMSduplicateMemory_call( (const void*)(source), \
180 /** moves the contents of one memory element into another memory element, should be used if both elements overlap,
190 /** allocates memory and copies the contents of the given memory element into the new memory element */
240 typedef struct BMS_ChkMem BMS_CHKMEM; /**< collection of memory chunks of the same element size */
245 #define BMScreateChunkMemory(sz,isz,gbf) BMScreateChunkMemory_call( (sz), (isz), (gbf), __FILE__, __LINE__ )
251 #define BMSallocChunkMemory(mem,ptr) ASSIGN((ptr), BMSallocChunkMemory_call((mem), sizeof(**(ptr)), \
256 #define BMSfreeChunkMemory(mem,ptr) { BMSfreeChunkMemory_call( (mem), (void*)(*(ptr)), sizeof(**(ptr)), \
259 #define BMSfreeChunkMemoryNull(mem,ptr) { if( *(ptr) != NULL ) BMSfreeChunkMemory( (mem), (ptr) ); }
282 /** aligns the given byte size corresponding to the minimal alignment for chunk and block memory */
330 /** duplicates a given memory element by allocating a new element of the same chunk block and copying the data */
350 /** calls garbage collection of chunk block and frees chunks without allocated memory elements */
380 #define BMSallocBlockMemoryArray(mem,ptr,num) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (num)*sizeof(**(ptr)), \
386 #define BMSallocBlockMemoryArray(mem,ptr,num) ( ( ((size_t)(num)) > UINT_MAX / sizeof(**(ptr)) ) \
398 #define BMScreateBlockMemory(csz,gbf) BMScreateBlockMemory_call( (csz), (gbf), __FILE__, __LINE__ )
404 #define BMSallocBlockMemory(mem,ptr) ASSIGN((ptr), BMSallocBlockMemory_call((mem), sizeof(**(ptr)), \
406 #define BMSallocBlockMemorySize(mem,ptr,size) ASSIGN((ptr), BMSallocBlockMemory_call((mem), (size_t)(size), \
417 #define BMSfreeBlockMemory(mem,ptr) { BMSfreeBlockMemory_call( (mem), (void*)(*(ptr)), sizeof(**(ptr)), \
420 #define BMSfreeBlockMemoryNull(mem,ptr) { if( *(ptr) != NULL ) BMSfreeBlockMemory( (mem), (ptr) ); }
421 #define BMSfreeBlockMemoryArray(mem,ptr,num) { BMSfreeBlockMemory_call( (mem), (void*)(*(ptr)), (num)*sizeof(**(ptr)), \
424 #define BMSfreeBlockMemoryArrayNull(mem,ptr,num) { if( *(ptr) != NULL ) BMSfreeBlockMemoryArray( (mem), (ptr), (num) ); }
425 #define BMSfreeBlockMemorySize(mem,ptr,size) { BMSfreeBlockMemory_call( (mem), (void*)(*(ptr)), (size_t)(size), \
428 #define BMSfreeBlockMemorySizeNull(mem,ptr,size) { if( *(ptr) != NULL ) BMSfreeBlockMemorySize( (mem), (ptr), (size) ); }
450 #define BMSduplicateBlockMemoryArray(mem, ptr, source, num) BMSduplicateMemoryArray(ptr,source,num)
531 /** calls garbage collection of block memory, frees chunks without allocated memory elements, and frees
545 /** returns the size of the given memory element; returns 0, if the element is not member of the block memory */
void BMSdestroyChunkMemory_call(BMS_CHKMEM **chkmem, const char *filename, int line) Definition: memory.c:1326 void BMSfreeMemory_call(void *ptr, const char *filename, int line) Definition: memory.c:433 void * BMSallocBlockMemory_call(BMS_BLKMEM *blkmem, size_t size, const char *filename, int line) Definition: memory.c:1626 BMS_CHKMEM * BMScreateChunkMemory_call(size_t size, int initchunksize, int garbagefactor, const char *filename, int line) Definition: memory.c:1284 void * BMSallocChunkMemory_call(BMS_CHKMEM *chkmem, size_t size, const char *filename, int line) Definition: memory.c:1346 void BMSclearBlockMemory_call(BMS_BLKMEM *blkmem, const char *filename, int line) Definition: memory.c:1571 void BMSdestroyBlockMemory_call(BMS_BLKMEM **blkmem, const char *filename, int line) Definition: memory.c:1604 void BMSfreeBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t size, const char *filename, int line) Definition: memory.c:1732 size_t BMSgetBlockPointerSize_call(const BMS_BLKMEM *blkmem, const void *ptr) Definition: memory.c:1826 void * BMSduplicateChunkMemory_call(BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line) Definition: memory.c:1373 void * BMSallocClearMemory_call(size_t num, size_t size, const char *filename, int line) Definition: memory.c:280 void * BMSduplicateMemory_call(const void *source, size_t size, const char *filename, int line) Definition: memory.c:414 void * BMSreallocBlockMemory_call(BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line) Definition: memory.c:1681 BMS_BLKMEM * BMScreateBlockMemory_call(int initchunksize, int garbagefactor, const char *filename, int line) Definition: memory.c:1541 void * BMSduplicateBlockMemory_call(BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line) Definition: memory.c:1712 void BMSgarbagecollectChunkMemory_call(BMS_CHKMEM *chkmem) Definition: memory.c:1422 void * BMSreallocMemory_call(void *ptr, size_t size, const char *filename, int line) Definition: memory.c:336 long long BMSgetBlockMemoryUsed_call(const BMS_BLKMEM *blkmem) Definition: memory.c:1816 void BMScheckEmptyBlockMemory_call(const BMS_BLKMEM *blkmem) Definition: memory.c:1969 long long BMSgetChunkMemoryUsed_call(const BMS_CHKMEM *chkmem) Definition: memory.c:1432 void BMSgarbagecollectBlockMemory_call(BMS_BLKMEM *blkmem) Definition: memory.c:1785 void * BMSallocMemory_call(size_t size, const char *filename, int line) Definition: memory.c:309 void BMSmoveMemory_call(void *ptr, const void *source, size_t size) Definition: memory.c:399 void BMScopyMemory_call(void *ptr, const void *source, size_t size) Definition: memory.c:382 void BMSdisplayBlockMemory_call(const BMS_BLKMEM *blkmem) Definition: memory.c:1846 void BMSclearChunkMemory_call(BMS_CHKMEM *chkmem, const char *filename, int line) Definition: memory.c:1308 void BMSfreeChunkMemory_call(BMS_CHKMEM *chkmem, void *ptr, size_t size, const char *filename, int line) Definition: memory.c:1395 |