diff options
Diffstat (limited to 'src/nvim/memory.h')
-rw-r--r-- | src/nvim/memory.h | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 5b9798dc0d..ffdc4c7366 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -1,12 +1,12 @@ -#ifndef NVIM_MEMORY_H -#define NVIM_MEMORY_H +#pragma once #include <stdbool.h> -#include <stddef.h> -#include <stdint.h> -#include <time.h> +#include <stdint.h> // IWYU pragma: keep +#include <time.h> // IWYU pragma: keep -#include "nvim/macros.h" +#include "auto/config.h" +#include "nvim/macros_defs.h" +#include "nvim/memory_defs.h" // IWYU pragma: export /// `malloc()` function signature typedef void *(*MemMalloc)(size_t); @@ -39,21 +39,7 @@ extern MemRealloc mem_realloc; extern bool entered_free_all_mem; #endif -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 } +EXTERN size_t arena_alloc_count INIT( = 0); #define kv_fixsize_arena(a, v, s) \ ((v).capacity = (s), \ @@ -73,4 +59,16 @@ typedef struct { (void)(*ptr_); \ } while (0) -#endif // NVIM_MEMORY_H +#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field)) +#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr))) + +#ifndef HAVE_STRNLEN +# define strnlen xstrnlen // Older versions of SunOS may not have strnlen +#endif + +#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf) + +// Like strcpy() but allows overlapped source and destination. +#define STRMOVE(d, s) memmove((d), (s), strlen(s) + 1) + +#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf) |