std::calloc
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <cstdlib>
|
||
| void* calloc( std::size_t num, std::size_t size ); |
||
num对象的大小size和零初始化的数组分配内存. Original:
Allocates memory for an array of
num objects of size size and zero-initializes it. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
如果分配成功,则返回一个指针到最低的(第一个)字节分配的内存块,适当的任何对象类型相一致.
Original:
If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any object type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
size是零,其行为是实现定义的(空指针可能会被退回,可能会被退回,可能无法用于访问存储或一些非空指针)Original:
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)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 参数
| num | - | 数目的对象
Original: number of objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| size | - | 每个对象的大小
Original: size of each object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
新分配的内存或NULL开始的指针,如果发生了错误。指针必须被释放
free().Original:
Pointer to the beginning of newly allocated memory or NULL if error has occurred. The pointer must be deallocated with
free().The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 注释
由于对齐的要求,分配的字节数不一定等于
num*sizeOriginal:
Due to the alignment requirements, the number of allocated bytes is not necessarily equal to
num*size.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
| 本节是不完整的 原因: no example |
[编辑] 另请参阅
| C documentation for calloc
|