释放calloc() [英] calloc()

查看:183
本文介绍了释放calloc()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




什么会导致calloc()返回NULL指针?


系统内存是否只是内存不足? br />

问候,


Michael

解决方案

Michael McGarry写道:





什么会导致calloc()返回NULL指针?


系统是否内存不足?



它不太可能出局。但是,它可能没有一块可用于你的程序足够大以填充请求。



Brian


我有什么办法可以解决这个问题吗?


我想如果没有我需要的大小的连续内存我就出去了<运气好吗?
运气好吗?

感谢您的帮助,


Michael


默认用户写道:


Michael McGarry写道:





会导致calloc()返回NULL指针的原因是什么?


系统是否只是内存不足?



它不太可能出局。但是,你的程序可能没有足够的空间来填写请求。



Brian


Michael McGarry写道:


>

默认用户写道:


>> Michael McGarry写道:


>>> Hi ,

什么会导致calloc()返回NULL指针?

系统是否只是内存不足?


它不太可能出局。但是,它可能没有可用于你的程序足够大以填充请求。



我有什么办法可以解决这个问题?


我想如果没有我需要的大小的连续记忆我就出去了

的运气?


感谢您的帮助,



请不要发帖。


假设你的实施有错误,你应该在确认失败原因之后测试它的价值




如果没有你需要的大小的连续记忆,你没有运气,应该考虑不同的设计。作为替代方案,请尝试早点分配更大的内存块。


-

Ian Collins。


Hi,

What would cause calloc() to return a NULL pointer?

Is the system simply out of memory?

Regards,

Michael

解决方案

Michael McGarry wrote:

Hi,

What would cause calloc() to return a NULL pointer?

Is the system simply out of memory?

It''s unlikely to be out. However, it may not have a piece available to
your program that is large enough to fill the request.


Brian


Is there anything I can do to fix that?

I guess if there is not contiguous memory of the size I need I am out
of luck?

Thanks for any help,

Michael

Default User wrote:

Michael McGarry wrote:

Hi,

What would cause calloc() to return a NULL pointer?

Is the system simply out of memory?


It''s unlikely to be out. However, it may not have a piece available to
your program that is large enough to fill the request.


Brian


Michael McGarry wrote:

>
Default User wrote:

>>Michael McGarry wrote:

>>>Hi,

What would cause calloc() to return a NULL pointer?

Is the system simply out of memory?


It''s unlikely to be out. However, it may not have a piece available to
your program that is large enough to fill the request.

Is there anything I can do to fix that?

I guess if there is not contiguous memory of the size I need I am out
of luck?

Thanks for any help,

Please don''t top post.

Assuming you implementation has errno, you should test its value after
the failing call to determine the cause of the failure.

If there isn''t contiguous memory of the size you need, you are out of
luck and should consider a different design. As an alternative, try
allocating the bigger memory blocks earlier.

--
Ian Collins.


这篇关于释放calloc()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆