refactor: move Arena and ArenaMem to memory_defs.h (#26240)

This commit is contained in:
zeertzjq
2023-11-27 17:21:58 +08:00
committed by GitHub
parent 84bbe4b0ca
commit 574d25642f
109 changed files with 274 additions and 309 deletions

View File

@@ -6,6 +6,7 @@
#include <time.h>
#include "nvim/macros.h"
#include "nvim/memory_defs.h" // IWYU pragma: export
/// `malloc()` function signature
typedef void *(*MemMalloc)(size_t);
@@ -40,20 +41,6 @@ extern bool entered_free_all_mem;
EXTERN size_t arena_alloc_count INIT( = 0);
typedef struct consumed_blk {
struct consumed_blk *prev;
} *ArenaMem;
#define ARENA_ALIGN MAX(sizeof(void *), sizeof(double))
typedef struct {
char *cur_blk;
size_t pos, size;
} Arena;
// inits an empty arena.
#define ARENA_EMPTY { .cur_blk = NULL, .pos = 0, .size = 0 }
#define kv_fixsize_arena(a, v, s) \
((v).capacity = (s), \
(v).items = (void *)arena_alloc(a, sizeof((v).items[0]) * (v).capacity, true))