refactor: move function macros out of vim_defs.h (#26300)

This commit is contained in:
zeertzjq
2023-11-29 23:10:21 +08:00
committed by GitHub
parent 18c1fd8e9d
commit 86cc791deb
22 changed files with 86 additions and 89 deletions

View File

@@ -4,6 +4,7 @@
#include <stdint.h> // IWYU pragma: keep
#include <time.h> // 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)