General Info | |
Interface: MemManager Files: lib/memmanager.h Last change: 14/02/2002 Author: Luiz Henrique Shigunov |
Description
Structures |
Functions | |
|
|
This page describes MemManager user interface.
The MemManager user interface provides dinamic memory allocation to programs/libraries.
typedef struct { unsigned int totalMem; unsigned int allocAreas; unsigned int totalAreas; unsigned int totalAlloc; unsigned int totalFree; unsigned int trimArea; } MemoryStats;
Where totalMem is the total space allocated from system, allocAreas is the number of areas allocated using AllocPages, totalAreas is the total space allocated using AllocPages, totalAlloc is the total allocated space, totalFree is the total free space and trimArea is the area that can be freed using MemTrim.
void *Alloc(unsigned int size);
This function allocates a memory chunk of at least size bytes.
void *AllocAlign(unsigned int align, unsigned int size);
This function allocates a memory chunk of at least size bytes, aligned in accord with align, which must be a power of 2.
void *AllocClear(unsigned int unit, unsigned int n);
This function allocates a memory chunk of at least unit * n bytes, with all locations set to zero.
void *AllocPageAlign(unsigned int size);
This function allocates a memory chunk of at least size bytes, aligned in a system page size.
void *AllocPageRound(unsigned int size);
This function allocates a memory chunk in a way that the minimal multiple of a system page >= size bytes.
That is, round up size to system page size and allocate a memory chunk of that size.
void Free(void *p);
This function frees the memory chunk p or does nothing if p is NULL.
MemoryStats GetMemStats(void);
This function gets some memory usage statistics.
unsigned int GetUsableSize(void *p);
This function gets the number of bytes usable in the memory chunk p.
This function can return more bytes usable than the one that were requested.
int MemTrim(unsigned int pad);
This function frees all but pad bytes of freed top-most memory back to the system.
void *ReAlloc(void *p, unsigned int size);
This function allocates a memory chunk of size that contains the same data as does chunk p up to the minimum of (size, p's size) bytes.
The returned pointer may or may not be the same as p.
If p is NULL, equivalent to Alloc.
If size is 0, equivalent to Free(p).
int SetMemOption(int option, void *value);
This function sets option to value.
option and value are dependent of the implementation. See the implementation docs.