nngn
Loading...
Searching...
No Matches
nngn::lua::alloc_info Struct Reference

Tracks state allocations. More...

#include <alloc.h>

Classes

struct  info
 Allocation information for each type. More...
 

Static Public Member Functions

static void * lua_alloc (void *d, void *p, std::size_t s0, std::size_t s1)
 Function to be passed to lua_newstate.
 
static void * lua_alloc (void *d, void *p, std::size_t s0, std::size_t s1)
 Function to be passed to lua_newstate.
 

Public Attributes

std::array< info, n_typesv = {}
 Total size in bytes of active allocations for each type.
 

Static Public Attributes

static constexpr std::array types
 Each entry corresponds to the allocation information in v.
 
static constexpr auto n_types = 1 + std::tuple_size_v<>
 Number of types for which allocations are tracked.
 

Detailed Description

Tracks state allocations.

Allocations are tracked for each of the types described in the lua_Alloc documentation (parameter osize), corresponding to the elements of the static array types. Each position in the array v contains the allocation information for the corresponding type in types. One extra position at the end (i.e. at position types.size()) holds information for "other" types.

lua_alloc is a static function which can serve as lua_Alloc allocator. Its d parameter should be the address of an object of this type. malloc(3), realloc(3), and free(3) will be used for actual memory allocations.

Member Function Documentation

◆ lua_alloc() [1/2]

void * nngn::lua::alloc_info::lua_alloc ( void *  d,
void *  p,
std::size_t  s0,
std::size_t  s1 
)
static

Function to be passed to lua_newstate.

Here is the caller graph for this function:

◆ lua_alloc() [2/2]

static void * nngn::lua::alloc_info::lua_alloc ( void *  d,
void *  p,
std::size_t  s0,
std::size_t  s1 
)
static

Function to be passed to lua_newstate.

Member Data Documentation

◆ n_types

static constexpr auto nngn::lua::alloc_info::n_types = 1 + std::tuple_size_v<>
staticconstexpr

Number of types for which allocations are tracked.

One extra position for "other".

◆ types

static constexpr std::array nngn::lua::alloc_info::types
staticconstexpr
Initial value:

Each entry corresponds to the allocation information in v.

◆ v

std::array< info, n_types > nngn::lua::alloc_info::v = {}

Total size in bytes of active allocations for each type.

Types are in the same order as types.


The documentation for this struct was generated from the following files: