0
0
mirror of https://github.com/vim/vim.git synced 2025-10-18 07:54:29 -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

@@ -1927,7 +1927,7 @@ window_new(win_T *win)
MZ_GC_REG();
self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window));
vim_memset(self, 0, sizeof(vim_mz_window));
CLEAR_POINTER(self);
#ifndef MZ_PRECISE_GC
scheme_dont_gc_ptr(self); // because win isn't visible to GC
#else
@@ -2311,7 +2311,7 @@ buffer_new(buf_T *buf)
MZ_GC_REG();
self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer));
vim_memset(self, 0, sizeof(vim_mz_buffer));
CLEAR_POINTER(self);
#ifndef MZ_PRECISE_GC
scheme_dont_gc_ptr(self); // because buf isn't visible to GC
#else
@@ -2634,8 +2634,7 @@ set_buffer_line_list(void *data, int argc, Scheme_Object **argv)
MZ_GC_VAR_IN_REG(1, rest);
MZ_GC_REG();
array = ALLOC_MULT(char *, new_len + 1);
vim_memset(array, 0, (new_len+1) * sizeof(char *));
array = ALLOC_CLEAR_MULT(char *, new_len + 1);
rest = line_list;
for (i = 0; i < new_len; ++i)
@@ -2818,8 +2817,7 @@ insert_buffer_line_list(void *data, int argc, Scheme_Object **argv)
MZ_GC_VAR_IN_REG(1, rest);
MZ_GC_REG();
array = ALLOC_MULT(char *, size + 1);
vim_memset(array, 0, (size+1) * sizeof(char *));
array = ALLOC_CLEAR_MULT(char *, size + 1);
rest = list;
for (i = 0; i < size; ++i)