From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/memory.h') diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 5b9798dc0d..862f7d9273 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -39,7 +39,7 @@ extern MemRealloc mem_realloc; extern bool entered_free_all_mem; #endif -EXTERN size_t arena_alloc_count INIT(= 0); +EXTERN size_t arena_alloc_count INIT( = 0); typedef struct consumed_blk { struct consumed_blk *prev; -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/memory.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/memory.h') diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 862f7d9273..100d991656 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MEMORY_H -#define NVIM_MEMORY_H +#pragma once #include #include @@ -72,5 +71,3 @@ typedef struct { *ptr_ = NULL; \ (void)(*ptr_); \ } while (0) - -#endif // NVIM_MEMORY_H -- cgit From 574d25642fc9ca65b396633aeab6e2d32778b642 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 17:21:58 +0800 Subject: refactor: move Arena and ArenaMem to memory_defs.h (#26240) --- src/nvim/memory.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/nvim/memory.h') diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 100d991656..18bcf11111 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -6,6 +6,7 @@ #include #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)) -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/memory.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/nvim/memory.h') diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 18bcf11111..c37866ebc5 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -1,11 +1,10 @@ #pragma once #include -#include -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: export /// `malloc()` function signature -- cgit From 86cc791debba09c8ed1aa0d863be844108866a38 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 23:10:21 +0800 Subject: refactor: move function macros out of vim_defs.h (#26300) --- src/nvim/memory.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/memory.h') diff --git a/src/nvim/memory.h b/src/nvim/memory.h index c37866ebc5..ffdc4c7366 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -4,6 +4,7 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep +#include "auto/config.h" #include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: export @@ -57,3 +58,17 @@ EXTERN size_t arena_alloc_count INIT( = 0); *ptr_ = NULL; \ (void)(*ptr_); \ } while (0) + +#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) -- cgit