MySQL 8.0.39
Source Code Documentation
|
Specialization of allocation routines for non-extended alignment types but which in comparison to Alloc are providing support for arrays. More...
#include <alloc.h>
Public Types | |
using | datalen_t = size_t |
This is the type we will be using to store the size of an array. More... | |
Static Public Member Functions | |
template<bool Zero_initialized> | |
static void * | alloc (std::size_t size) noexcept |
Sanity check so that we can be sure that our metadata segment can fit the datalen_t. More... | |
static void | free (void *ptr) noexcept |
Releases storage dynamically allocated through Alloc_arr::alloc(). More... | |
static datalen_t | datalen (void *ptr) |
Returns the size of an array in bytes. More... | |
Static Public Attributes | |
static constexpr auto | metadata_len = alignof(max_align_t) |
This is how much the metadata (ALLOC-ARR-META) segment will be big. More... | |
Static Public Attributes inherited from ut::detail::allocator_traits< false > | |
static constexpr auto | is_pfs_instrumented_v |
Static Private Member Functions | |
static void * | deduce (void *ptr) noexcept |
Helper function which deduces the original pointer returned by Alloc_arr::alloc() from a pointer which is passed to us by the call-site. More... | |
Specialization of allocation routines for non-extended alignment types but which in comparison to Alloc are providing support for arrays.
To provide support for arrays, these allocation routines will allocate extra (metadata) space so that they can serialize the requested size of an array (in bytes) into the memory. That will enable higher-kinded functions, implemented on top of Alloc, to take necessary actions such as cleaning up the resources by invoking appropriate number of destructors of non-trivially-destructible types. Otherwise, this would create a burden on end users by having to remember and carry the array size all around the code. This is equivalent to what we find in other standard implementations. For example, new int x[10] is always released without passing the array size: delete[] x; The same holds with this design.
Memory layout representation looks like the following:
^ ^ | | | | | ptr to be returned to call-site
\ \ 0 \ alignof(max_align_t) - 1
DATALEN segment encodes the total length of DATA segment, which is the actual allocation size that client code has requested.
DATA segment is a segment that will be returned to the call-site.
using ut::detail::Alloc_arr::datalen_t = size_t |
This is the type we will be using to store the size of an array.
|
inlinestaticnoexcept |
Sanity check so that we can be sure that our metadata segment can fit the datalen_t.
Sanity check so that we can be sure that the size of our metadata segment is such so that the pointer to DATA segment is always suitably aligned (multiple of alignof(max_align_t). Dynamically allocates storage of given size.
[in] | size | Size of storage (in bytes) requested to be allocated. |
|
inlinestatic |
Returns the size of an array in bytes.
[in] | ptr | Pointer to storage allocated through Alloc_arr::alloc(). |
|
inlinestaticprivatenoexcept |
Helper function which deduces the original pointer returned by Alloc_arr::alloc() from a pointer which is passed to us by the call-site.
|
inlinestaticnoexcept |
Releases storage dynamically allocated through Alloc_arr::alloc().
[in] | ptr | Pointer to storage allocated through Alloc_arr::alloc(). |
|
staticconstexpr |
This is how much the metadata (ALLOC-ARR-META) segment will be big.