commit 6361806aa28edca55ad3316a58bc3e936df9c0eb parent 34509bbea3e8c6a8033911aea645b1b5579f7d1a Author: zeertzjq <zeertzjq@outlook.com> Date: Sun, 26 Nov 2023 22:58:52 +0800 refactor: move garray_T to garray_defs.h (#26227) Diffstat:
42 files changed, 51 insertions(+), 48 deletions(-)
diff --git a/Makefile b/Makefile @@ -162,7 +162,6 @@ iwyu: build/.ran-cmake |src/nvim/api/window.h\ |src/nvim/arabic.h\ |src/nvim/arglist.h\ - |src/nvim/arglist_defs.h\ |src/nvim/ascii.h\ |src/nvim/assert.h\ |src/nvim/autocmd.h\ @@ -313,7 +312,6 @@ iwyu: build/.ran-cmake |src/nvim/spell.h\ |src/nvim/spell_defs.h\ |src/nvim/spellfile.h\ - |src/nvim/spellsuggest.h\ |src/nvim/state.h\ |src/nvim/statusline.h\ |src/nvim/statusline_defs.h\ diff --git a/cmake.config/iwyu/mapping.imp b/cmake.config/iwyu/mapping.imp @@ -198,11 +198,13 @@ { include: [ '"nvim/arglist_defs.h"', public, '"nvim/arglist.h"', public ] }, { include: [ '"nvim/buffer_defs.h"', public, '"nvim/buffer.h"', public ] }, { include: [ '"nvim/cmdexpand_defs.h"', public, '"nvim/cmdexpand.h"', public ] }, + { include: [ '"nvim/decoration_defs.h"', public, '"nvim/decoration.h"', public ] }, { include: [ '"nvim/eval/typval_defs.h"', public, '"nvim/eval/typval.h"', public ] }, { include: [ '"nvim/ex_cmds_defs.h"', public, '"nvim/ex_cmds.h"', public ] }, { include: [ '"nvim/ex_eval_defs.h"', public, '"nvim/ex_eval.h"', public ] }, { include: [ '"nvim/extmark_defs.h"', public, '"nvim/extmark.h"', public ] }, { include: [ '"nvim/fold_defs.h"', public, '"nvim/fold.h"', public ] }, + { include: [ '"nvim/garray_defs.h"', public, '"nvim/garray.h"', public ] }, { include: [ '"nvim/getchar_defs.h"', public, '"nvim/getchar.h"', public ] }, { include: [ '"nvim/grid_defs.h"', public, '"nvim/grid.h"', public ] }, { include: [ '"nvim/highlight_defs.h"', public, '"nvim/highlight.h"', public ] }, diff --git a/src/clint.py b/src/clint.py @@ -916,7 +916,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/api/window.h", "src/nvim/arabic.h", "src/nvim/arglist.h", - "src/nvim/arglist_defs.h", "src/nvim/ascii.h", "src/nvim/assert.h", "src/nvim/autocmd.h", @@ -1067,7 +1066,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/spell.h", "src/nvim/spell_defs.h", "src/nvim/spellfile.h", - "src/nvim/spellsuggest.h", "src/nvim/state.h", "src/nvim/statusline.h", "src/nvim/statusline_defs.h", diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c @@ -13,7 +13,6 @@ #include "nvim/api/vimscript.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/extmark.h" #include "nvim/globals.h" #include "nvim/highlight.h" diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c @@ -13,7 +13,6 @@ #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/drawscreen.h" #include "nvim/extmark.h" diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c @@ -11,7 +11,6 @@ #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/drawscreen.h" #include "nvim/globals.h" #include "nvim/grid.h" diff --git a/src/nvim/arglist_defs.h b/src/nvim/arglist_defs.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/garray.h" +#include "nvim/garray_defs.h" /// Argument list: Array of file names. /// Used for the global argument list and the argument lists local to a window. diff --git a/src/nvim/assert.h b/src/nvim/assert.h @@ -1,6 +1,7 @@ #pragma once #include "auto/config.h" +#include "nvim/log.h" // support static asserts (aka compile-time asserts) diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h @@ -19,7 +19,7 @@ typedef struct { #include "nvim/arglist_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/extmark_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/grid_defs.h" #include "nvim/hashtab.h" #include "nvim/highlight_defs.h" diff --git a/src/nvim/channel.c b/src/nvim/channel.c @@ -18,6 +18,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/socket.h" #include "nvim/event/wstream.h" +#include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" diff --git a/src/nvim/channel.h b/src/nvim/channel.h @@ -10,7 +10,7 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/event/stream.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/macros.h" #include "nvim/main.h" #include "nvim/map.h" diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c @@ -26,6 +26,7 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/cmdexpand.h b/src/nvim/cmdexpand.h @@ -3,7 +3,7 @@ #include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_getln.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/types.h" // Values for nextwild() and ExpandOne(). See ExpandOne() for meaning. diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c @@ -15,7 +15,6 @@ #include "nvim/cursor.h" #include "nvim/cursor_shape.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" #include "nvim/drawline.h" diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c @@ -68,7 +68,6 @@ #include "nvim/cmdexpand.h" #include "nvim/cursor.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" #include "nvim/digraph.h" diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h @@ -8,7 +8,7 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/vim.h" /// Convert Vimscript value to msgpack string diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c @@ -18,6 +18,7 @@ #include "nvim/eval/userfunc.h" #include "nvim/eval/vars.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/hashtab.h" diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h @@ -8,7 +8,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/func_attr.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/lib/queue.h" diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h @@ -3,7 +3,7 @@ #include <inttypes.h> #include <limits.h> -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/hashtab.h" #include "nvim/lib/queue.h" #include "nvim/pos.h" diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c @@ -24,6 +24,7 @@ #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h @@ -7,7 +7,7 @@ #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/hashtab.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c @@ -31,7 +31,6 @@ #include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/extmark.h" #include "nvim/extmark_defs.h" #include "nvim/globals.h" diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c @@ -31,6 +31,7 @@ #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h @@ -3,7 +3,7 @@ #include "nvim/buffer_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/globals.h" #include "nvim/os/fs_defs.h" #include "nvim/os/os.h" diff --git a/src/nvim/fold.c b/src/nvim/fold.c @@ -20,7 +20,6 @@ #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/diff.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" @@ -29,6 +28,7 @@ #include "nvim/extmark.h" #include "nvim/fold.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/indent.h" diff --git a/src/nvim/fold.h b/src/nvim/fold.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" #include "nvim/fold_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/macros.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/garray.h b/src/nvim/garray.h @@ -3,24 +3,11 @@ #include <stdbool.h> #include <stddef.h> +#include "nvim/garray_defs.h" #include "nvim/log.h" #include "nvim/memory.h" #include "nvim/types.h" -/// Structure used for growing arrays. -/// This is used to store information that only grows, is deleted all at -/// once, and needs to be accessed by index. See ga_clear() and ga_grow(). -typedef struct growarray { - int ga_len; // current number of items used - int ga_maxlen; // maximum number of items possible - int ga_itemsize; // sizeof(item) - int ga_growsize; // number of items to grow each time - void *ga_data; // pointer to the first item -} garray_T; - -#define GA_EMPTY_INIT_VALUE { 0, 0, 0, 1, NULL } -#define GA_INIT(itemsize, growsize) { 0, 0, (itemsize), (growsize), NULL } - #define GA_EMPTY(ga_ptr) ((ga_ptr)->ga_len <= 0) #define GA_APPEND(item_type, gap, item) \ diff --git a/src/nvim/garray_defs.h b/src/nvim/garray_defs.h @@ -0,0 +1,17 @@ +#pragma once + +#include <stddef.h> + +/// Structure used for growing arrays. +/// This is used to store information that only grows, is deleted all at +/// once, and needs to be accessed by index. See ga_clear() and ga_grow(). +typedef struct growarray { + int ga_len; // current number of items used + int ga_maxlen; // maximum number of items possible + int ga_itemsize; // sizeof(item) + int ga_growsize; // number of items to grow each time + void *ga_data; // pointer to the first item +} garray_T; + +#define GA_EMPTY_INIT_VALUE { 0, 0, 0, 1, NULL } +#define GA_INIT(itemsize, growsize) { 0, 0, (itemsize), (growsize), NULL } diff --git a/src/nvim/main.c b/src/nvim/main.c @@ -12,6 +12,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef ENABLE_ASAN_UBSAN +# include <sanitizer/asan_interface.h> +# include <sanitizer/ubsan_interface.h> +#endif #include "nvim/arglist.h" #include "nvim/ascii.h" @@ -2227,13 +2231,11 @@ static void check_swap_exists_action(void) } #ifdef ENABLE_ASAN_UBSAN -const char *__ubsan_default_options(void); // NOLINT(bugprone-reserved-identifier) const char *__ubsan_default_options(void) { return "print_stacktrace=1"; } -const char *__asan_default_options(void); // NOLINT(bugprone-reserved-identifier) const char *__asan_default_options(void) { return "handle_abort=1,handle_sigill=1"; diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c @@ -56,6 +56,7 @@ // only for debug functions #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/garray_defs.h" #include "nvim/macros.h" #define T MT_BRANCH_FACTOR diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h @@ -8,7 +8,7 @@ #include "klib/kvec.h" #include "nvim/assert.h" #include "nvim/decoration_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/map.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h @@ -5,7 +5,7 @@ #include "nvim/buffer_defs.h" #include "nvim/cmdexpand_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/os/fs_defs.h" #include "nvim/os/stdpaths_defs.h" #include "nvim/types.h" diff --git a/src/nvim/path.c b/src/nvim/path.c @@ -16,6 +16,7 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros.h" diff --git a/src/nvim/path.h b/src/nvim/path.h @@ -1,7 +1,7 @@ #pragma once #include "nvim/func_attr.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/types.h" // Flags for expand_wildcards() diff --git a/src/nvim/plines.c b/src/nvim/plines.c @@ -8,7 +8,6 @@ #include "nvim/ascii.h" #include "nvim/charset.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/diff.h" #include "nvim/fold.h" #include "nvim/globals.h" diff --git a/src/nvim/rbuffer.h b/src/nvim/rbuffer.h @@ -16,8 +16,6 @@ #include <stddef.h> #include <stdint.h> -struct rbuffer; - // Macros that simplify working with the read/write pointers directly by hiding // ring buffer wrap logic. Some examples: // diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h @@ -8,7 +8,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/option_defs.h" #include "nvim/pos.h" #include "nvim/types.h" diff --git a/src/nvim/sign.c b/src/nvim/sign.c @@ -18,7 +18,6 @@ #include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/decoration.h" -#include "nvim/decoration_defs.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/eval/funcs.h" diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h @@ -4,7 +4,7 @@ #include <stdint.h> #include "nvim/buffer_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/regexp_defs.h" #include "nvim/types.h" diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c @@ -18,6 +18,7 @@ #include "nvim/eval/typval.h" #include "nvim/fileio.h" #include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/spellsuggest.h b/src/nvim/spellsuggest.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "spellsuggest.h.generated.h" diff --git a/src/nvim/usercmd.h b/src/nvim/usercmd.h @@ -5,7 +5,7 @@ #include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/types.h" typedef struct ucmd {