std::malloc (3) - Linux Man Pages
Defined in header <cstdlib>
void* malloc( std::size_t size );
Allocates size bytes of uninitialized storage.
If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any scalar type.
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, but has to be passed to std::free)
The following functions are required to be thread-safe:
* The library versions of operator_new and operator_delete
* User replacement versions of global operator_new and operator_delete
* std::calloc, std::malloc, std::realloc (since C++11)
Calls to these functions that allocate or deallocate a particular unit of storage occur in a single total order, and each such deallocation call happens-before the next allocation (if any) in this order.
size - number of bytes to allocate
On success, returns the pointer to the beginning of newly allocated memory. To avoid a memory leak, the returned pointer must be deallocated with std::free() or std::realloc().
On failure, returns a null pointer.
This function does not call constructors or initialize memory in any way. There are no ready-to-use smart pointers that could guarantee that the matching deallocation function is called. The preferred method of memory allocation in C++ is using RAII-ready functions std::make_unique, std::make_shared, container constructors, etc, and, in low-level library code, new-expression.
// Run this code
get_temporary_buffer obtains uninitialized storage
(deprecated in C++17)
(removed in C++20)