GENERAL: MALLOC ALWAYS RETURNS NULL
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.
Last Reviewed: Thursday, November 15, 2001
of your data.