aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memory.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /src/nvim/memory.h
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'src/nvim/memory.h')
-rw-r--r--src/nvim/memory.h42
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)