nngn
Loading...
Searching...
No Matches
alloc.h
Go to the documentation of this file.
1#ifndef NNGN_LUA_ALLOC_H
2#define NNGN_LUA_ALLOC_H
3
4#include <array>
5#include <cstddef>
6#include <tuple>
7
8#include "utils/ranges.h"
9#include "utils/utils.h"
10
11#include "lua.h"
12
13namespace nngn::lua {
14
29struct alloc_info {
31 static void *lua_alloc(void *d, void *p, std::size_t s0, std::size_t s1);
33 static constexpr std::array types = {
36 };
41 static constexpr auto n_types = 1 + std::tuple_size_v<decltype(types)>;
42 static_assert(is_sequence(types, to_underlying<type>));
47 struct info { std::size_t n, bytes; };
52 std::array<info, n_types> v = {};
53};
54
55}
56
57#endif
Definition lua_audio.cpp:19
constexpr auto to_underlying(T t)
Definition utils.h:138
constexpr bool is_sequence(R &&r, Proj proj={})
Definition ranges.h:119
Definition types.h:32
Allocation information for each type.
Definition alloc.h:47
std::size_t bytes
Definition alloc.h:47
std::size_t n
Definition alloc.h:47
Tracks state allocations.
Definition alloc.h:29
static constexpr auto n_types
Number of types for which allocations are tracked.
Definition alloc.h:41
static constexpr std::array types
Each entry corresponds to the allocation information in v.
Definition alloc.h:33
std::array< info, n_types > v
Total size in bytes of active allocations for each type.
Definition alloc.h:52
static void * lua_alloc(void *d, void *p, std::size_t s0, std::size_t s1)
Function to be passed to lua_newstate.
Definition alloc.cpp:102