34 #include <exec/types.h> 35 #include <exec/memory.h> 36 #include <exec/semaphores.h> 37 #include <clib/exec_protos.h> 38 #define ALLOC_MEM(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR) 39 #define FREE_MEM(x) FreeVec(x) 43 #define ALLOC_MEM(x) calloc(1L
,x) 44 #define FREE_MEM(x) free(x) 48 #if defined(__x86_64__
) || defined(__aarch64__) || 49 defined(_M_AMD64) || defined(_M_ARM64) || 50 defined(__powerpc64__) 108 allocsize = (size + 7) & ~0x07;
111 allocsize = (size + 3) & ~0x03;
129 newblock
->size = allocsize;
148 if (
list ==
nullptr || block ==
nullptr)
154 if (block ==
nullptr)
162 while (current !=
nullptr && current
->address != block)
168 if (current ==
nullptr)
174 if (previous ==
nullptr)
227 while (current !=
nullptr)
242 void MemUsage(
long* blocks,
long* size,
long* peak)
254 Debug(
"Memory allocation error (%s) with size (%d)\n", descr, size);
264 Debug(
"Memory deallocation error (%s) address (%x)\n", descr, p);
struct MemoryBlock * first
void alloc_error(char *, size_t)
Log a memory allocation error.
struct MemoryBlock * next
Block of allocated memory.
void MemUsage(long *blocks, long *size, long *peak)
Get memory usage in the global memory list.
struct MemoryList * list
Global list of allocated memory.
void RemoveMemSafe(void *block, bool deallocate)
void * AllocMemSafe(size_t size)
Allocate memory and add it to the global memory list.
void FreeMemSafe(void *block)
Deallocate memory from the global memory list.
void dealloc_error(char *, void *)
Log a memory deallocation error.
void FreeAllSafe()
Deallocate all memory in the global memory list.
List of allocated memory. Uses the LIFO principle.
void DetachMemSafe(void *block)
Detach an allocated memory from the global memory list.