博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
alloca()与malloc的区别
阅读量:4139 次
发布时间:2019-05-25

本文共 539 字,大约阅读时间需要 1 分钟。

void*   realloc(void*   ptr,   unsigned   newsize);  

void*   malloc(unsigned   size);  

void*   alloca(unsigned   size);  

void*   calloc(size_t   numElements,   size_t   sizeOfElement);  

都在stdlib.h函数库内  

 

 

alloca 和malloc 的 区别我是alloca是在栈上申请  

malloc是在堆上申请

 

alloca is not Standard and cannot be used in programs which must be widely portable, no matter how useful it might be. Now that C99 supports variable-length arrays (VLA's), they can be used to more cleanly accomplish most of the tasks which alloca used to be put to.

void fun()

{

int size = INT_MAX / 8;

char a[size];

}

转载地址:http://vhmvi.baihongyu.com/

你可能感兴趣的文章
手机内存卡应该叫外存卡
查看>>
哈希表之简易数学原理和简易实现(史上最简单易懂的哈希表介绍)
查看>>
Restep into the English World
查看>>
kk音标导读(上):赖世雄老师26个英语字母导读示范 (附我备注)
查看>>
memset, string, 段错误?---谈谈我遇到的memset误用
查看>>
gdb调试器学习与总结(熟能生巧)
查看>>
今天下午desktop不能和某嵌入式设备通信---找到原因后, 快笑晕了。
查看>>
kk音标导读(下):赖世雄老师26个英语字母导读示范 (附我备注)
查看>>
赖世雄精准美国英语音标发音指南01 (附我备注)
查看>>
赖世雄精准美国英语音标发音指南02 (附我备注)
查看>>
赖世雄精准美国英语音标发音指南03 (附我备注)
查看>>
赖世雄精准美国英语音标发音指南04(附我备注)
查看>>
《过得刚好》 郭德纲
查看>>
fork函数详解(fork就是分叉的意思, 很形象)
查看>>
那一年, fork() 函数弄晕了多少Windows程序猿
查看>>
以亲身感受浅谈程序的注释和一个bug的代价(单位:RMB)
查看>>
当printf("-")遇上fork() ---某公司招聘笔试题目
查看>>
谢孟媛老师英语音标发音01(附我备注)
查看>>
谢孟媛老师英语音标发音02(附我备注)
查看>>
如何用C语言判断ip地址是否合法? (用inet_addr有问题)
查看>>