一直疑惑不知道在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.
上一篇:51單片機最小系統
下一篇:8051單片機-校驗和
推薦閱讀最新更新時間:2025-06-07 23:38
設計資源 培訓 開發板 精華推薦
- 意法半導體緊湊型可配置車規負載驅動器具備安全引腳
- 美光宣布在美投資增至 2000 億美元,加建晶圓廠和 HBM 封裝設施
- AMD舉辦Advancing AI 2025大會:Instinct MI350系列GPU發布,35倍推理性能提升
- 特斯拉起訴前Optimus機器人工程師,指控其竊取商業機密
- Nordic Semiconductor將在MWC上海2025上展示前沿蜂窩物聯網解決方案
- SiC 市場的下一個爆點:共源共柵(cascode)結構詳解
- 香港科技大學工學院推出擬人化自動駕駛系統
- 現代摩比斯推出新型安全技術 防止追尾碰撞
- 研究人員開發新型機器人系統 利用AI賦能機器人技術
- 研究人員開發具有突破性觸覺靈敏度的機械手 可實現類人靈巧操作