简体   繁体   English

Calloc-内存分配

[英]Calloc - Memory allocation

Does calloc allocate return contiguous memory location? calloc是否分配返回连续的内存位置? If yes, what would it do if it is not available? 如果是,如果不可用怎么办?

Does calloc allocate returns contiguous memory location? calloc是否分配返回连续的内存位置?

Yes. 是。 1 1

what would it do if it is not available? 如果不可用怎么办?

Return NULL . 返回NULL

See section 7.20.3.1 of the C99 standard. 请参阅C99标准的7.20.3.1节。


1. So far as the C program is concerned. 1.就C程序而言。 In a virtual memory system, the underlying physical memory used may not be contiguous. 在虚拟内存系统中,使用的基础物理内存可能不是连续的。

是的,C标准保证calloc返回的指针为NULL或指向连续内存块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM