init_mempool()

发布时间: 2024-07-30
来源: 电子工程世界

一直疑惑不知道在51中是否能使用malloc,使用malloc需要做什么准备。后来看到了内存池初始化函数,查了一下资料init_mempool()函数申请的内存空间专为calloc,free, malloc, and realloc函数使用。见下方红字。

init_mempool

Summary: #include
void init_mempool (
void xdata *p, /* start of memory pool */
unsigned int size); /* length of memory pool */

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
This function must be used to setup the memory pool before
any other memory management functions (calloc, free,
malloc, realloc) can be called. Call the init_mempool
function only once at the beginning of your program.
Source code is provided for this routine in the folder
KEILC51LIB. You can modify the source to customize this
function for your hardware environment. Refer to
“Chapter 6. Advanced Programming Techniques” on page
149 for more information.
Return Value: None.


文章来源于: 电子工程世界 原文链接

本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。