Most memory allocation involves nothing more than calling AllocMem()
to allocate memory and FreeMem()
to free memory. Here is a simple example.
Example 1: Allocating memory.
#include "types.h" #include "mem.h" #include "stdio.h" int main(int32 argc, char **argv) { void *memBlock; memBlock = AllocMem(123,MEMTYPE_ANY); /* allocate any type of memory */ if (memBlock) { /* memBlock now contains the address of a block of memory * 123 bytes in size */ FreeMem(memBlock,123); /* return the memory */ } else { printf("Could not allocate memory!\n"); } }