init_mempool()

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

init_mempool

Summary: #include <stdlib.h>
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
\KEIL\C51\LIB. 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.

转载于:https://www.cnblogs.com/JoJosBizarreAdventure/p/4651807.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值