 | Cx51 User's Guide |  |
|
|
| init_mempool| Summary | | | Description | The init_mempool function initializes the memory management routines and provides the starting address and size of the memory pool. The p argument points to a memory area in xdata which is managed using the calloc, free, malloc, and realloc library functions. The size argument specifies the number of bytes to use for the memory pool. Note | | Return Value | None. | | See Also | calloc, free, malloc, realloc | | Example |
#include <stdlib.h>
unsigned char xdata malloc_mempool [0x1000];
void tst_init_mempool (void) {
int i;
xdata void *p;
init_mempool (&malloc_mempool, sizeof(malloc_mempool));
p = malloc (100);
for (i = 0; i < 100; i++)
((char *) p)[i] = i;
free (p);
}
|
|
|