std::calloc
来自cppreference.com
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 在头文件 <cstdlib> 中定义
|
||
| void* calloc( std::size_t num, std::size_t size ); |
||
num对象的大小size和零初始化的数组分配内存. 原文:
Allocates memory for an array of
num objects of size size and zero-initializes it. 如果分配成功,则返回一个指针到最低的(第一个)字节分配的内存块,适当的任何对象类型相一致.
原文:
If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any object type.
size是零,其行为是实现定义的(空指针可能会被退回,可能会被退回,可能无法用于访问存储或一些非空指针)原文:
If
size is zero, the behavior is implementation defined (null pointer may be returned, or some non-null pointer may be returned that may not be used to access storage)目录 |
[编辑] 参数
| num | - | 数目的对象
|
| size | - | 每个对象的大小
|
[编辑] 返回值
新分配的内存或NULL开始的指针,如果发生了错误。指针必须被释放
free().原文:
Pointer to the beginning of newly allocated memory or NULL if error has occurred. The pointer must be deallocated with
free().[编辑] 注释
由于对齐的要求,分配的字节数不一定等于
num*size原文:
Due to the alignment requirements, the number of allocated bytes is not necessarily equal to
num*size.[编辑] 示例
| 本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
| C documentation for calloc
|