|ARM Technical Support Knowledge Articles|
Applies to: General Topics
Information in this article applies to:
I'm using the malloc function to allocate memory but it always returns NULL. What's going on?
The memory pool must be initialized before you use the memory allocation routines (malloc, free, alloc, and calloc).
Use init_mempool to initialize the memory pool. For example:
init_mempool (0x8000, 0x1000);
unsigned char mempool_buffer [0x1000]; init_mempool (mempoolbuffer, sizeof (mempool_buffer));
This defines the memory pool (from which memory is allocated by malloc) to start at 0x8000 for 4K bytes (0x1000).
Refer to the C51, C166, or C251 User's Guides for information about this routine.
Article last edited on: 2001-11-15 00:00:00
Did you find this article helpful? Yes No
How can we improve this article?