std::malloc
来自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* malloc( std::size_t size ); |
||
分配
size个字节的未初始化的存储.Original:
Allocates
size bytes of uninitialized 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.
如果分配成功,则返回一个指针到最低的(第一个)字节分配的内存块,适当的任何对象类型相一致.
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.
目录 |
[编辑] 参数
| size | - | 要分配的字节数
Original: number of bytes to allocate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
如果发生了错误,开始新分配的内存或空指针的指针。指针必须被释放
free().Original:
Pointer to the beginning of newly allocated memory or null pointer 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.
[编辑] 注释
此函数不调用构造函数或内存进行初始化,以任何方式。因此,首选的内存分配方法是new表达.
Original:
This function does not call constructors or initialize memory in any way. Thus preferred method of memory allocation is new expression.
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 |
[编辑] 另请参阅
| 分配的功能 Original: allocation functions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
| 获得未初始化的存储 Original: obtains uninitialized storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) | |
| C documentation for malloc
| |