This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical reasons).
More...
|
void | sql_alloc_error_handler () |
|
void * | operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept |
| Allocate an object of the given type. More...
|
|
void * | operator new[] (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept |
|
void | operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept |
|
void | operator delete[] (void *, MEM_ROOT *, const std::nothrow_t &) noexcept |
|
template<class T > |
void | destroy (T *ptr) |
|
template<class T > |
void | destroy_array (T *ptr, size_t count) |
|
template<typename T , typename... Args> |
unique_ptr_destroy_only< T > | make_unique_destroy_only (MEM_ROOT *mem_root, Args &&...args) |
|
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical reasons).
void * operator new |
( |
size_t |
size, |
|
|
MEM_ROOT * |
mem_root, |
|
|
const std::nothrow_t & |
arg = std::nothrow |
|
) |
| |
|
inlinenoexcept |
Allocate an object of the given type.
Use like this:
Foo *foo = new (mem_root) Foo();
Note that unlike regular operator new, this will not throw exceptions. However, it can return nullptr if the capacity of the MEM_ROOT has been reached. This is allowed since it is not a replacement for global operator new, and thus isn't used automatically by e.g. standard library containers.
TODO: This syntax is confusing in that it could look like allocating a MEM_ROOT using regular placement new. We should make a less ambiguous syntax, e.g. new (On(mem_root)) Foo().