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. |
| Заголовочный файл <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.
[править] Notes
Эта функция не вызывать конструкторы или инициализации памяти в любом случае. Таким образом, предпочтительный способ распределения памяти является 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.
[править] Пример
| Этот раздел не завершён Причина: нет примера |
[править] См. также
| Распределение функций 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 документация для malloc
| |