summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-12 19:37:17 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-12 19:37:17 +0200
commita80faa8930ed5a554beeb2727762538873135e83 (patch)
treee797605e0c781214543fcba103cffede7af611cd
parent82de464f763d6e6d89229be03ce7c6d02fd5fb59 (diff)
patch 8.2.0559: clearing a struct is verbosev8.2.0559
Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER().
-rw-r--r--src/blowfish.c2
-rw-r--r--src/channel.c10
-rw-r--r--src/charset.c2
-rw-r--r--src/clipboard.c2
-rw-r--r--src/diff.c10
-rw-r--r--src/eval.c14
-rw-r--r--src/evalfunc.c8
-rw-r--r--src/ex_cmds2.c4
-rw-r--r--src/ex_docmd.c10
-rw-r--r--src/ex_getln.c12
-rw-r--r--src/findfile.c3
-rw-r--r--src/gui_gtk_f.c2
-rw-r--r--src/gui_mac.c2
-rw-r--r--src/gui_motif.c2
-rw-r--r--src/gui_w32.c6
-rw-r--r--src/gui_x11.c2
-rw-r--r--src/hardcopy.c6
-rw-r--r--src/hashtab.c6
-rw-r--r--src/highlight.c20
-rw-r--r--src/if_mzsch.c10
-rw-r--r--src/if_py_both.h34
-rw-r--r--src/insexpand.c2
-rw-r--r--src/kword_test.c2
-rw-r--r--src/list.c2
-rw-r--r--src/main.c2
-rw-r--r--src/map.c2
-rw-r--r--src/memfile.c4
-rw-r--r--src/message_test.c2
-rw-r--r--src/misc1.c2
-rw-r--r--src/netbeans.c2
-rw-r--r--src/normal.c6
-rw-r--r--src/ops.c2
-rw-r--r--src/option.c4
-rw-r--r--src/os_mswin.c8
-rw-r--r--src/os_win32.c2
-rw-r--r--src/popupmenu.c2
-rw-r--r--src/quickfix.c10
-rw-r--r--src/regexp.c2
-rw-r--r--src/regexp_bt.c2
-rw-r--r--src/regexp_nfa.c4
-rw-r--r--src/search.c2
-rw-r--r--src/sign.c2
-rw-r--r--src/spell.c10
-rw-r--r--src/spellfile.c4
-rw-r--r--src/spellsuggest.c4
-rw-r--r--src/syntax.c6
-rw-r--r--src/tag.c6
-rw-r--r--src/terminal.c28
-rw-r--r--src/time.c2
-rw-r--r--src/undo.c10
-rw-r--r--src/userfunc.c10
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h14
-rw-r--r--src/vim9compile.c6
-rw-r--r--src/vim9execute.c4
55 files changed, 170 insertions, 169 deletions
diff --git a/src/blowfish.c b/src/blowfish.c
index af5e2fc003..74d8e5416f 100644
--- a/src/blowfish.c
+++ b/src/blowfish.c
@@ -514,7 +514,7 @@ bf_self_test(void)
UINT32_T ui = 0xffffffffUL;
bf_state_T state;
- vim_memset(&state, 0, sizeof(bf_state_T));
+ CLEAR_FIELD(state);
state.cfb_len = BF_MAX_CFB_LEN;
// We can't simply use sizeof(UINT32_T), it would generate a compiler
diff --git a/src/channel.c b/src/channel.c
index 8f15c659bf..0d86423b69 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -977,7 +977,7 @@ channel_open(
// Get the server internet address and put into addr structure fill in the
// socket address structure and connect to server.
#ifdef FEAT_IPV6
- vim_memset(&hints, 0, sizeof(hints));
+ CLEAR_FIELD(hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
# ifdef AI_ADDRCONFIG
@@ -1037,7 +1037,7 @@ channel_open(
freeaddrinfo(res);
#else
- vim_memset((char *)&server, 0, sizeof(server));
+ CLEAR_FIELD(server);
server.sin_family = AF_INET;
server.sin_port = htons(port);
if ((host = gethostbyname(hostname)) == NULL)
@@ -2514,7 +2514,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
exarg_T ea;
ch_log(channel, "Executing normal command '%s'", (char *)arg);
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.arg = arg;
ea.addr_count = 0;
ea.forceit = TRUE; // no mapping
@@ -2525,7 +2525,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
exarg_T ea;
ch_log(channel, "redraw");
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.forceit = *arg != NUL;
ex_redraw(&ea);
showruler(FALSE);
@@ -4793,7 +4793,7 @@ handle_io(typval_T *item, ch_part_T part, jobopt_T *opt)
void
clear_job_options(jobopt_T *opt)
{
- vim_memset(opt, 0, sizeof(jobopt_T));
+ CLEAR_POINTER(opt);
}
/*
diff --git a/src/charset.c b/src/charset.c
index aa843d111a..7415c24719 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -127,7 +127,7 @@ buf_init_chartab(
/*
* Init word char flags all to FALSE
*/
- vim_memset(buf->b_chartab, 0, (size_t)32);
+ CLEAR_FIELD(buf->b_chartab);
if (enc_dbcs != 0)
for (c = 0; c < 256; ++c)
{
diff --git a/src/clipboard.c b/src/clipboard.c
index e9e426f52d..7a35112d25 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -2033,7 +2033,7 @@ clip_get_selection(Clipboard_T *cbd)
clear_oparg(&oa);
oa.regname = (cbd == &clip_plus ? '+' : '*');
oa.op_type = OP_YANK;
- vim_memset(&ca, 0, sizeof(ca));
+ CLEAR_FIELD(ca);
ca.oap = &oa;
ca.cmdchar = 'y';
ca.count1 = 1;
diff --git a/src/diff.c b/src/diff.c
index 3d61d49d1c..16389fd92c 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -939,14 +939,14 @@ ex_diffupdate(exarg_T *eap) // "eap" can be NULL
goto theend;
// Only use the internal method if it did not fail for one of the buffers.
- vim_memset(&diffio, 0, sizeof(diffio));
+ CLEAR_FIELD(diffio);
diffio.dio_internal = diff_internal() && !diff_internal_failed();
diff_try_update(&diffio, idx_orig, eap);
if (diffio.dio_internal && diff_internal_failed())
{
// Internal diff failed, use external diff instead.
- vim_memset(&diffio, 0, sizeof(diffio));
+ CLEAR_FIELD(diffio);
diff_try_update(&diffio, idx_orig, eap);
}
@@ -1075,9 +1075,9 @@ diff_file_internal(diffio_T *diffio)
xdemitconf_t emit_cfg;
xdemitcb_t emit_cb;
- vim_memset(&param, 0, sizeof(param));
- vim_memset(&emit_cfg, 0, sizeof(emit_cfg));
- vim_memset(&emit_cb, 0, sizeof(emit_cb));
+ CLEAR_FIELD(param);
+ CLEAR_FIELD(emit_cfg);
+ CLEAR_FIELD(emit_cb);
param.flags = diff_algorithm;
diff --git a/src/eval.c b/src/eval.c
index 3b789dadc6..fbbae637a9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -234,7 +234,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
s = expr->vval.v_string;
if (s == NULL || *s == NUL)
return FAIL;
- vim_memset(&funcexe, 0, sizeof(funcexe));
+ CLEAR_FIELD(funcexe);
funcexe.evaluate = TRUE;
if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL)
return FAIL;
@@ -253,7 +253,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
s = partial_name(partial);
if (s == NULL || *s == NUL)
return FAIL;
- vim_memset(&funcexe, 0, sizeof(funcexe));
+ CLEAR_FIELD(funcexe);
funcexe.evaluate = TRUE;
funcexe.partial = partial;
if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL)
@@ -475,7 +475,7 @@ call_vim_function(
funcexe_T funcexe;
rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this
- vim_memset(&funcexe, 0, sizeof(funcexe));
+ CLEAR_FIELD(funcexe);
funcexe.firstline = curwin->w_cursor.lnum;
funcexe.lastline = curwin->w_cursor.lnum;
funcexe.evaluate = TRUE;
@@ -649,7 +649,7 @@ get_lval(
int quiet = flags & GLV_QUIET;
// Clear everything in "lp".
- vim_memset(lp, 0, sizeof(lval_T));
+ CLEAR_POINTER(lp);
if (skip)
{
@@ -1715,7 +1715,7 @@ eval_func(
funcexe_T funcexe;
// Invoke the function.
- vim_memset(&funcexe, 0, sizeof(funcexe));
+ CLEAR_FIELD(funcexe);
funcexe.firstline = curwin->w_cursor.lnum;
funcexe.lastline = curwin->w_cursor.lnum;
funcexe.evaluate = evaluate;
@@ -2805,7 +2805,7 @@ call_func_rettv(
else
s = (char_u *)"";
- vim_memset(&funcexe, 0, sizeof(funcexe));
+ CLEAR_FIELD(funcexe);
funcexe.firstline = curwin->w_cursor.lnum;
funcexe.lastline = curwin->w_cursor.lnum;
funcexe.evaluate = evaluate;
@@ -5507,7 +5507,7 @@ clear_tv(typval_T *varp)
init_tv(typval_T *varp)
{
if (varp != NULL)
- vim_memset(varp, 0, sizeof(typval_T));
+ CLEAR_POINTER(varp);
}
/*
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 8ce8c8751d..4b9b4ed5ae 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -2977,7 +2977,7 @@ f_get(typval_T *argvars, typval_T *rettv)
pt = argvars[0].vval.v_partial;
else
{
- vim_memset(&fref_pt, 0, sizeof(fref_pt));
+ CLEAR_FIELD(fref_pt);
fref_pt.pt_name = argvars[0].vval.v_string;
pt = &fref_pt;
}
@@ -6530,7 +6530,7 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
}
pos = save_cursor = curwin->w_cursor;
- vim_memset(&sia, 0, sizeof(sia));
+ CLEAR_FIELD(sia);
sia.sa_stop_lnum = (linenr_T)lnum_stop;
#ifdef FEAT_RELTIME
sia.sa_tm = &tm;
@@ -6978,7 +6978,7 @@ do_searchpair(
{
searchit_arg_T sia;
- vim_memset(&sia, 0, sizeof(sia));
+ CLEAR_FIELD(sia);
sia.sa_stop_lnum = lnum_stop;
#ifdef FEAT_RELTIME
sia.sa_tm = &tm;
@@ -8401,7 +8401,7 @@ f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
lnum = tv_get_lnum(argvars); // -1 on type error
col = (colnr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
- vim_memset(str, NUL, sizeof(str));
+ CLEAR_FIELD(str);
if (rettv_list_alloc(rettv) != FAIL)
{
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 59f04a59a8..a0f383982f 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -168,7 +168,7 @@ dialog_changed(
// Init ea pseudo-structure, this is needed for the check_overwrite()
// function.
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
if (ret == VIM_YES)
{
@@ -889,7 +889,7 @@ source_pyx_file(exarg_T *eap, char_u *fname)
* unobtrusive message.
*/
if (eap == NULL)
- vim_memset(&ex, 0, sizeof(ex));
+ CLEAR_FIELD(ex);
else
ex = *eap;
ex.arg = fname;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index b04e2832a7..d979f43efc 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -728,7 +728,7 @@ do_cmdline(
if (flags & DOCMD_EXCRESET)
save_dbg_stuff(&debug_saved);
else
- vim_memset(&debug_saved, 0, sizeof(debug_saved));
+ CLEAR_FIELD(debug_saved);
initial_trylevel = trylevel;
@@ -1663,7 +1663,7 @@ do_one_cmd(
int starts_with_colon;
#endif
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.line1 = 1;
ea.line2 = 1;
#ifdef FEAT_EVAL
@@ -2626,7 +2626,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
{
char_u *p;
- vim_memset(&cmdmod, 0, sizeof(cmdmod));
+ CLEAR_FIELD(cmdmod);
eap->verbose_save = -1;
eap->save_msg_silent = -1;
@@ -5631,7 +5631,7 @@ handle_drop_internal(void)
* Move to the first file.
*/
// Fake up a minimal "next" command for do_argfile()
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.cmd = (char_u *)"next";
do_argfile(&ea, 0);
@@ -5898,7 +5898,7 @@ tabpage_new(void)
{
exarg_T ea;
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.cmdidx = CMD_tabnew;
ea.cmd = (char_u *)"tabn";
ea.arg = (char_u *)"";
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 4b0645a504..accedb5403 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -218,7 +218,7 @@ do_incsearch_highlighting(int firstc, int *search_delim, incsearch_state_T *is_s
return FALSE;
++emsg_off;
- vim_memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
ea.line1 = 1;
ea.line2 = 1;
ea.cmd = ccline.cmdbuff;
@@ -459,7 +459,7 @@ may_do_incsearch_highlighting(
search_flags += SEARCH_START;
ccline.cmdbuff[skiplen + patlen] = NUL;
#ifdef FEAT_RELTIME
- vim_memset(&sia, 0, sizeof(sia));
+ CLEAR_FIELD(sia);
sia.sa_tm = &tm;
#endif
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
@@ -758,7 +758,7 @@ cmdline_has_arabic(int start, int len)
void
cmdline_init(void)
{
- vim_memset(&ccline, 0, sizeof(cmdline_info_T));
+ CLEAR_FIELD(ccline);
}
/*
@@ -834,7 +834,7 @@ getcmdline_int(
did_save_ccline = TRUE;
}
if (init_ccline)
- vim_memset(&ccline, 0, sizeof(cmdline_info_T));
+ CLEAR_FIELD(ccline);
#ifdef FEAT_EVAL
if (firstc == -1)
@@ -2464,7 +2464,7 @@ getcmdline_prompt(
did_save_ccline = TRUE;
}
- vim_memset(&ccline, 0, sizeof(cmdline_info_T));
+ CLEAR_FIELD(ccline);
ccline.cmdprompt = prompt;
ccline.cmdattr = attr;
# ifdef FEAT_EVAL
@@ -3504,7 +3504,7 @@ save_cmdline(cmdline_info_T *ccp)
{
if (!prev_ccline_used)
{
- vim_memset(&prev_ccline, 0, sizeof(cmdline_info_T));
+ CLEAR_FIELD(prev_ccline);
prev_ccline_used = TRUE;
}
*ccp = prev_ccline;
diff --git a/src/findfile.c b/src/findfile.c
index ba996c4546..a6bec9788a 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -320,10 +320,9 @@ vim_findfile_init(
search_ctx = search_ctx_arg;
else
{
- search_ctx = ALLOC_ONE(ff_search_ctx_T);
+ search_ctx = ALLOC_CLEAR_ONE(ff_search_ctx_T);
if (search_ctx == NULL)
goto error_return;
- vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T));
}
search_ctx->ffsc_find_what = find_what;
search_ctx->ffsc_tagfile = tagfile;
diff --git a/src/gui_gtk_f.c b/src/gui_gtk_f.c
index ff9aee8f05..2a9e5a0872 100644
--- a/src/gui_gtk_f.c
+++ b/src/gui_gtk_f.c
@@ -223,7 +223,7 @@ gtk_form_get_type(void)
{
GtkTypeInfo form_info;
- vim_memset(&form_info, 0, sizeof(form_info));
+ CLEAR_FIELD(form_info);
form_info.type_name = "GtkForm";
form_info.object_size = sizeof(GtkForm);
form_info.class_size = sizeof(GtkFormClass);
diff --git a/src/gui_mac.c b/src/gui_mac.c
index 875b3ecc13..b37d3f5a03 100644
--- a/src/gui_mac.c
+++ b/src/gui_mac.c
@@ -5451,7 +5451,7 @@ gui_mch_dialog(
button = 0;
// initialize the hotkey mapping
- vim_memset(hotKeys, 0, sizeof(hotKeys));
+ CLEAR_FIELD(hotKeys);
for (;*buttonChar != 0;)
{
diff --git a/src/gui_motif.c b/src/gui_motif.c
index 28b080a4a8..022626bcb0 100644
--- a/src/gui_motif.c
+++ b/src/gui_motif.c
@@ -1956,7 +1956,7 @@ do_mnemonic(Widget w, unsigned int keycode)
XmProcessTraversal(w, XmTRAVERSE_CURRENT);
- vim_memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent));
+ CLEAR_FIELD(keyEvent);
keyEvent.type = KeyPress;
keyEvent.serial = 1;
keyEvent.send_event = True;
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 5af41059d2..2409ee68e4 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -3504,7 +3504,7 @@ gui_mch_browse(
// Convert the filter to Windows format.
filterp = convert_filterW(filter);
- vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
+ CLEAR_FIELD(fileStruct);
# ifdef OPENFILENAME_SIZE_VERSION_400W
// be compatible with Windows NT 4.0
fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
@@ -4267,7 +4267,7 @@ _OnMouseWheel(
// Mouse hovers over popup window, scroll it if possible.
mouse_row = wp->w_winrow;
mouse_col = wp->w_wincol;
- vim_memset(&cap, 0, sizeof(cap));
+ CLEAR_FIELD(cap);
cap.arg = zDelta < 0 ? MSCR_UP : MSCR_DOWN;
cap.cmdchar = zDelta < 0 ? K_MOUSEUP : K_MOUSEDOWN;
clear_oparg(&oa);
@@ -6478,7 +6478,7 @@ gui_mch_add_menu_item(
{
TBBUTTON newtb;
- vim_memset(&newtb, 0, sizeof(newtb));
+ CLEAR_FIELD(newtb);
if (menu_is_separator(menu->name))
{
newtb.iBitmap = 0;
diff --git a/src/gui_x11.c b/src/gui_x11.c
index ce619f654c..f05de7bac8 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -2267,7 +2267,7 @@ gui_mch_get_rgb_color(int r, int g, int b)
return (guicolor_T)available.pixel;
#endif
colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));
- vim_memset(&available, 0, sizeof(XColor));
+ CLEAR_FIELD(available);
available.red = r << 8;
available.green = g << 8;
available.blue = b << 8;
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 36473cd48b..a6df816316 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -558,7 +558,7 @@ ex_hardcopy(exarg_T *eap)
int page_line;
int jobsplit;
- vim_memset(&settings, 0, sizeof(prt_settings_T));
+ CLEAR_FIELD(settings);
settings.has_color = TRUE;
# ifdef FEAT_POSTSCRIPT
@@ -681,7 +681,7 @@ ex_hardcopy(exarg_T *eap)
prt_pos_T page_prtpos; // print position at page start
int side;
- vim_memset(&page_prtpos, 0, sizeof(prt_pos_T));
+ CLEAR_FIELD(page_prtpos);
page_prtpos.file_line = eap->line1;
prtpos = page_prtpos;
@@ -1844,7 +1844,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
semsg(_("E624: Can't open file \"%s\""), resource->filename);
return FALSE;
}
- vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN);
+ CLEAR_FIELD(prt_resfile.buffer);
// Parse first line to ensure valid resource file
prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u),
diff --git a/src/hashtab.c b/src/hashtab.c
index f43469fc34..816dcf7933 100644
--- a/src/hashtab.c
+++ b/src/hashtab.c
@@ -65,7 +65,7 @@ hash_create(void)
hash_init(hashtab_T *ht)
{
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
- vim_memset(ht, 0, sizeof(hashtab_T));
+ CLEAR_POINTER(ht);
ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1;
}
@@ -394,11 +394,12 @@ hash_may_resize(
}
else
oldarray = ht->ht_array;
+ CLEAR_FIELD(ht->ht_smallarray);
}
else
{
// Allocate an array.
- newarray = ALLOC_MULT(hashitem_T, newsize);
+ newarray = ALLOC_CLEAR_MULT(hashitem_T, newsize);
if (newarray == NULL)
{
// Out of memory. When there are NULL items still return OK.
@@ -411,7 +412,6 @@ hash_may_resize(
}
oldarray = ht->ht_array;
}
- vim_memset(newarray, 0, (size_t)(sizeof(hashitem_T) * newsize));
/*
* Move all the items from the old array to the new one, placing them in
diff --git a/src/highlight.c b/src/highlight.c
index 9f8bfbc7f2..ee2e43754d 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -2141,7 +2141,7 @@ get_attr_entry(garray_T *table, attrentry_T *aep)
return 0;
taep = &(((attrentry_T *)table->ga_data)[table->ga_len]);
- vim_memset(taep, 0, sizeof(attrentry_T));
+ CLEAR_POINTER(taep);
taep->ae_attr = aep->ae_attr;
#ifdef FEAT_GUI
if (table == &gui_attr_table)
@@ -2189,7 +2189,7 @@ get_cterm_attr_idx(int attr, int fg, int bg)
{
attrentry_T at_en;
- vim_memset(&at_en, 0, sizeof(attrentry_T));
+ CLEAR_FIELD(at_en);
#ifdef FEAT_TERMGUICOLORS
at_en.ae_u.cterm.fg_rgb = INVALCOLOR;
at_en.ae_u.cterm.bg_rgb = INVALCOLOR;
@@ -2211,7 +2211,7 @@ get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
{
attrentry_T at_en;
- vim_memset(&at_en, 0, sizeof(attrentry_T));
+ CLEAR_FIELD(at_en);
at_en.ae_attr = attr;
if (fg == INVALCOLOR && bg == INVALCOLOR)
{
@@ -2239,7 +2239,7 @@ get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
{
attrentry_T at_en;
- vim_memset(&at_en, 0, sizeof(attrentry_T));
+ CLEAR_FIELD(at_en);
at_en.ae_attr = attr;
at_en.ae_u.gui.fg_color = fg;
at_en.ae_u.gui.bg_color = bg;
@@ -2298,7 +2298,7 @@ hl_combine_attr(int char_attr, int prim_attr)
new_en = *char_aep;
else
{
- vim_memset(&new_en, 0, sizeof(new_en));
+ CLEAR_FIELD(new_en);
new_en.ae_u.gui.fg_color = INVALCOLOR;
new_en.ae_u.gui.bg_color = INVALCOLOR;
new_en.ae_u.gui.sp_color = INVALCOLOR;
@@ -2341,7 +2341,7 @@ hl_combine_attr(int char_attr, int prim_attr)
new_en = *char_aep;
else
{
- vim_memset(&new_en, 0, sizeof(new_en));
+ CLEAR_FIELD(new_en);
#ifdef FEAT_TERMGUICOLORS
new_en.ae_u.cterm.bg_rgb = INVALCOLOR;
new_en.ae_u.cterm.fg_rgb = INVALCOLOR;
@@ -2393,7 +2393,7 @@ hl_combine_attr(int char_attr, int prim_attr)
new_en = *char_aep;
else
{
- vim_memset(&new_en, 0, sizeof(new_en));
+ CLEAR_FIELD(new_en);
if (char_attr <= HL_ALL)
new_en.ae_attr = char_attr;
}
@@ -3062,7 +3062,7 @@ syn_add_group(char_u *name)
return 0;
}
- vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(hl_group_T));
+ CLEAR_POINTER(&(HL_TABLE()[highlight_ga.ga_len]));
HL_TABLE()[highlight_ga.ga_len].sg_name = name;
HL_TABLE()[highlight_ga.ga_len].sg_name_u = name_up;
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
@@ -3262,7 +3262,7 @@ combine_stl_hlt(
if (id_alt == 0)
{
- vim_memset(&hlt[hlcnt + i], 0, sizeof(hl_group_T));
+ CLEAR_POINTER(&hlt[hlcnt + i]);
hlt[hlcnt + i].sg_term = highlight_attr[hlf];
hlt[hlcnt + i].sg_cterm = highlight_attr[hlf];
# if defined(FEAT_GUI) || defined(FEAT_EVAL)
@@ -3457,7 +3457,7 @@ highlight_changed(void)
{
// Make sure id_S is always valid to simplify code below. Use the last
// entry.
- vim_memset(&HL_TABLE()[hlcnt + 27], 0, sizeof(hl_group_T));
+ CLEAR_POINTER(&HL_TABLE()[hlcnt + 27]);
HL_TABLE()[hlcnt + 18].sg_term = highlight_attr[HLF_S];
id_S = hlcnt + 19;
}
diff --git a/src/if_mzsch.c b/src/if_mzsch.c
index 0ee922daa7..8cc2e21454 100644
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -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)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 77ec4a9931..5a878bd2bd 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -3200,7 +3200,7 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
if (self->argv || self->self)
{
- vim_memset(&pt, 0, sizeof(partial_T));
+ CLEAR_FIELD(pt);
set_partial(self, &pt, FALSE);
pt_ptr = &pt;
}
@@ -6420,7 +6420,7 @@ static PyTypeObject CurrentType;
static void
init_structs(void)
{
- vim_memset(&OutputType, 0, sizeof(OutputType));
+ CLEAR_FIELD(OutputType);
OutputType.tp_name = "vim.message";
OutputType.tp_basicsize = sizeof(OutputObject);
OutputType.tp_flags = Py_TPFLAGS_DEFAULT;
@@ -6440,7 +6440,7 @@ init_structs(void)
// OutputType.tp_base = &PyFile_Type;
#endif
- vim_memset(&IterType, 0, sizeof(IterType));
+ CLEAR_FIELD(IterType);
IterType.tp_name = "vim.iter";
IterType.tp_basicsize = sizeof(IterObject);
It