|
amath
1.8.5
Simple command line calculator
|

Go to the source code of this file.
Classes | |
| struct | MemoryBlock |
| Block of allocated memory. More... | |
| struct | MemoryList |
| List of allocated memory. Uses the LIFO principle. More... | |
Macros | |
| #define | ALLOC_MEM(x) calloc(1L,x) |
| #define | FREE_MEM(x) free(x) |
| #define | Debug(x, y, z) |
Functions | |
| void | alloc_error (char *descr, size_t size) |
| Log a memory allocation error. More... | |
| void | dealloc_error (char *descr, void *p) |
| Log a memory deallocation error. More... | |
| void * | AllocMemSafe (size_t size) |
| Allocate memory and add it to the global memory list. More... | |
| void | RemoveMemSafe (void *block, bool deallocate) |
| void | FreeMemSafe (void *block) |
| Deallocate memory from the global memory list. More... | |
| void | DetachMemSafe (void *block) |
| Detach an allocated memory from the global memory list. More... | |
| void | FreeAllSafe () |
| Deallocate all memory in the global memory list. More... | |
| void | MemUsage (long *blocks, long *size, long *peak) |
| Get memory usage in the global memory list. More... | |
Variables | |
| struct MemoryList * | list = nullptr |
| Global list of allocated memory. More... | |
| void alloc_error | ( | char * | descr, |
| size_t | size | ||
| ) |
Log a memory allocation error.
Definition at line 252 of file mem.c.
Referenced by AllocMemSafe().

| void* AllocMemSafe | ( | size_t | size | ) |
Allocate memory and add it to the global memory list.
Definition at line 86 of file mem.c.
References MemoryBlock::address, alloc_error(), MemoryList::count, MemoryList::first, list, MemoryBlock::next, MemoryList::peak, MemoryBlock::size, and MemoryList::size.

| void dealloc_error | ( | char * | descr, |
| void * | p | ||
| ) |
| void DetachMemSafe | ( | void * | block | ) |
Detach an allocated memory from the global memory list.
The memory block is only detached, not deallocated.
Definition at line 209 of file mem.c.
References RemoveMemSafe().

| void FreeAllSafe | ( | ) |
Deallocate all memory in the global memory list.
Definition at line 217 of file mem.c.
References MemoryBlock::address, MemoryList::first, list, and MemoryBlock::next.
Referenced by main().

| void FreeMemSafe | ( | void * | block | ) |
Deallocate memory from the global memory list.
Definition at line 200 of file mem.c.
References RemoveMemSafe().

| void MemUsage | ( | long * | blocks, |
| long * | size, | ||
| long * | peak | ||
| ) |
Get memory usage in the global memory list.
Definition at line 242 of file mem.c.
References MemoryList::count, list, MemoryList::peak, and MemoryList::size.
Referenced by MemoryStatement::Execute().

| void RemoveMemSafe | ( | void * | block, |
| bool | deallocate | ||
| ) |
Definition at line 144 of file mem.c.
References MemoryBlock::address, MemoryList::count, dealloc_error(), MemoryList::first, list, MemoryBlock::next, MemoryBlock::size, and MemoryList::size.
Referenced by DetachMemSafe(), and FreeMemSafe().


| struct MemoryList* list = nullptr |
Global list of allocated memory.
Definition at line 78 of file mem.c.
Referenced by AllocMemSafe(), FreeAllSafe(), MemUsage(), and RemoveMemSafe().