|
#define | GET_DWORDFROMPBYTE(src) |
| Get u32 from u8 array (BigEndian order).
|
|
#define | GET_DWORDFROMPBYTE_LI(src) |
| Get u32 from u8 array (LittleEndian order).
|
|
#define | GET_WORDFROMPBYTE(src) |
| Get u16 from u8 array (BigEndian order).
|
|
#define | GET_WORDFROMPBYTE_LI(src) |
| Get u16 from u8 array (LittleEndian order).
|
|
#define | GET_DWORDFROMPWORD(src) |
| Get u32 from u16 array (BigEndian order).
|
|
#define | GET_DWORDFROMPWORD_LI(src) |
| Get u32 from u16 array (LittleEndian order).
|
|
#define | SWAP_u8(x, y) |
| Exchange value of specified u8 variables.
|
|
#define | SWAP_s8(x, y) |
| Exchange value of specified s8 variables.
|
|
#define | SWAP_u16(x, y) |
| Exchange value of specified u16 variables.
|
|
#define | SWAP_s16(x, y) |
| Exchange value of specified s16 variables.
|
|
#define | SWAP_u32(x, y) |
| Exchange value of specified u32 variables.
|
|
#define | SWAP_s32(x, y) |
| Exchange value of specified s32 variables.
|
|
#define | malloc(x) |
|
#define | free(x) |
|
#define | memcpyU16(to, from, len) |
|
#define | memcpyU32(to, from, len) |
|
#define | fastMemset(to, value, len) |
|
#define | fastMemsetU16(to, value, len) |
|
#define | fastMemsetU32(to, value, len) |
|
#define | astMemcpy(to, from, len) |
|
#define | fastMemcpyU16(to, from, len) |
|
#define | fastMemcpyU32(to, from, len) |
|
|
u16 | MEM_getFree (void) |
| Return available memory in bytes.
|
|
u16 | MEM_getAllocated (void) |
| Return allocated memory in bytes.
|
|
u16 | MEM_getLargestFreeBlock (void) |
| Return largest free memory block in bytes.
|
|
void | MEM_free (void *ptr) |
| Deallocate space in memory.
|
|
void * | MEM_alloc (u16 size) |
| Allocate memory block.
|
|
void * | MEM_allocAt (u32 addr, u16 size) |
| Allocate memory block at a specific address (useful for short addressing or fixed low level working address)
|
|
void | MEM_pack (void) |
| Pack all free blocks and reset allocation search from start of heap.
You can call this method before trying to allocate small block of memory to reduce memory fragmentation.
|
|
void | MEM_dump (void) |
| Show memory dump.
|
|
void | memset (void *to, u8 value, u16 len) |
| Fill block of memory.
|
|
void | memsetU16 (u16 *to, u16 value, u16 len) |
| Fill block of memory (optimized for u16)
|
|
void | memsetU32 (u32 *to, u32 value, u16 len) |
| Fill block of memory (optimized for u32)
|
|
void | memcpy (void *to, const void *from, u16 len) |
| Copy block of memory.
|
|
Memory handling methods.
- Author
- Stephane Dallongeville
- Date
- 08/2011
This unit provides memory copy/set operation and dynamic memory allocation.
Memory organization :
Memory is composed of bloc, the first 2 bytes of a bloc define its size and its state:
b15-b1 = size in number of word (2 bytes)
b0 = used state (1=used, 0=free)
To reach the next bloc you just need to do:
next_bloc_address = bloc_addres + bloc_size
The end of memory is defined with a 0 sized bloc.
void MEM_free |
( |
void * | ptr | ) |
|
Deallocate space in memory.
- Parameters
-
ptr | Pointer to a memory block previously allocated with Mem_alloc to be deallocated.
If a null pointer is passed as argument, no action occurs. |
A block of memory previously allocated using a call to Mem_alloc is deallocated, making it available again for further allocations. Notice that this function leaves the value of ptr unchanged, hence it still points to the same (now invalid) location, and not to the null pointer.