0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0559: clearing a struct is verbose

Problem:    Clearing a struct is verbose.
Solution:   Define and use CLEAR_FIELD() and CLEAR_POINTER().
This commit is contained in:
Bram Moolenaar
2020-04-12 19:37:17 +02:00
parent 82de464f76
commit a80faa8930
55 changed files with 170 additions and 169 deletions

View File

@@ -1575,6 +1575,14 @@ typedef UINT32_TYPEDEF UINT32_T;
#define LALLOC_CLEAR_MULT(type, count) (type *)lalloc_clear(sizeof(type) * (count), FALSE)
#define LALLOC_MULT(type, count) (type *)lalloc(sizeof(type) * (count), FALSE)
#ifdef HAVE_MEMSET
# define vim_memset(ptr, c, size) memset((ptr), (c), (size))
#else
void *vim_memset(void *, int, size_t);
#endif
#define CLEAR_FIELD(field) vim_memset(&(field), 0, sizeof(field))
#define CLEAR_POINTER(ptr) vim_memset((ptr), 0, sizeof(*(ptr)))
/*
* defines to avoid typecasts from (char_u *) to (char *) and back
* (vim_strchr() and vim_strrchr() are now in alloc.c)
@@ -1708,12 +1716,6 @@ typedef void *vim_acl_T; // dummy to pass an ACL to a function
#define fnamecmp(x, y) vim_fnamecmp((char_u *)(x), (char_u *)(y))
#define fnamencmp(x, y, n) vim_fnamencmp((char_u *)(x), (char_u *)(y), (size_t)(n))
#ifdef HAVE_MEMSET
# define vim_memset(ptr, c, size) memset((ptr), (c), (size))
#else
void *vim_memset(void *, int, size_t);
#endif
#if defined(UNIX) || defined(FEAT_GUI) || defined(VMS) \
|| defined(FEAT_CLIENTSERVER)
# define USE_INPUT_BUF