Use memset instead of vim_memset

Ran some commands on terminal, reviewed changes, and made some manual changes
too.

    find src | xargs perl -i -p -e "s/vim_memset/memset/g"
    git grep -l memset | egrep "\.c$" | xargs perl -i -p -e \
        's/(#include "vim\.h")/#include <string.h>\n\n\1/g'
This commit is contained in:
Felipe Oliveira Carvalho 2014-03-24 20:30:14 -03:00 committed by Thiago de Arruda
parent 68bc6bce29
commit ed3e9d51ac
29 changed files with 143 additions and 109 deletions

View File

@ -11,6 +11,8 @@
* Based on http://www.schneier.com/blowfish.html by Bruce Schneier. * Based on http://www.schneier.com/blowfish.html by Bruce Schneier.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "blowfish.h" #include "blowfish.h"
#include "message.h" #include "message.h"
@ -500,7 +502,7 @@ static char_u ofb_buffer[BF_OFB_LEN]; // 64 bytes
void bf_ofb_init(char_u *iv, int iv_len) void bf_ofb_init(char_u *iv, int iv_len)
{ {
randbyte_offset = update_offset = 0; randbyte_offset = update_offset = 0;
vim_memset(ofb_buffer, 0, BF_OFB_LEN); memset(ofb_buffer, 0, BF_OFB_LEN);
if (iv_len > 0) { if (iv_len > 0) {
int mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN; int mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN;

View File

@ -2,6 +2,8 @@
/// ///
/// Code related to character sets. /// Code related to character sets.
#include <string.h>
#include "vim.h" #include "vim.h"
#include "charset.h" #include "charset.h"
#include "farsi.h" #include "farsi.h"
@ -129,7 +131,7 @@ int buf_init_chartab(buf_T *buf, int global)
} }
// Init word char flags all to FALSE // Init word char flags all to FALSE
vim_memset(buf->b_chartab, 0, (size_t)32); memset(buf->b_chartab, 0, (size_t)32);
if (enc_dbcs != 0) { if (enc_dbcs != 0) {
for (c = 0; c < 256; ++c) { for (c = 0; c < 256; ++c) {

View File

@ -11,6 +11,8 @@
* edit.c: functions for Insert mode * edit.c: functions for Insert mode
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "edit.h" #include "edit.h"
#include "buffer.h" #include "buffer.h"
@ -3504,7 +3506,7 @@ int ins_compl_add_tv(typval_T *tv, int dir)
aempty = get_dict_number(tv->vval.v_dict, (char_u *)"empty"); aempty = get_dict_number(tv->vval.v_dict, (char_u *)"empty");
} else { } else {
word = get_tv_string_chk(tv); word = get_tv_string_chk(tv);
vim_memset(cptext, 0, sizeof(cptext)); memset(cptext, 0, sizeof(cptext));
} }
if (word == NULL || (!aempty && *word == NUL)) if (word == NULL || (!aempty && *word == NUL))
return FAIL; return FAIL;

View File

@ -11,6 +11,8 @@
* eval.c: Expression evaluation. * eval.c: Expression evaluation.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "eval.h" #include "eval.h"
#include "buffer.h" #include "buffer.h"
@ -2333,7 +2335,7 @@ get_lval (
int quiet = flags & GLV_QUIET; int quiet = flags & GLV_QUIET;
/* Clear everything in "lp". */ /* Clear everything in "lp". */
vim_memset(lp, 0, sizeof(lval_T)); memset(lp, 0, sizeof(lval_T));
if (skip) { if (skip) {
/* When skipping just find the end of the name. */ /* When skipping just find the end of the name. */
@ -14431,7 +14433,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv)
lnum = get_tv_lnum(argvars); /* -1 on type error */ lnum = get_tv_lnum(argvars); /* -1 on type error */
col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */
vim_memset(str, NUL, sizeof(str)); memset(str, NUL, sizeof(str));
if (rettv_list_alloc(rettv) != FAIL) { if (rettv_list_alloc(rettv) != FAIL) {
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
@ -16112,7 +16114,7 @@ void clear_tv(typval_T *varp)
static void init_tv(typval_T *varp) static void init_tv(typval_T *varp)
{ {
if (varp != NULL) if (varp != NULL)
vim_memset(varp, 0, sizeof(typval_T)); memset(varp, 0, sizeof(typval_T));
} }
/* /*
@ -17691,7 +17693,7 @@ trans_function_name (
lval_T lv; lval_T lv;
if (fdp != NULL) if (fdp != NULL)
vim_memset(fdp, 0, sizeof(funcdict_T)); memset(fdp, 0, sizeof(funcdict_T));
start = *pp; start = *pp;
/* Check for hard coded <SNR>: already translated function ID (from a user /* Check for hard coded <SNR>: already translated function ID (from a user
@ -18476,7 +18478,7 @@ call_user_func (
v->di_tv.v_type = VAR_LIST; v->di_tv.v_type = VAR_LIST;
v->di_tv.v_lock = VAR_FIXED; v->di_tv.v_lock = VAR_FIXED;
v->di_tv.vval.v_list = &fc->l_varlist; v->di_tv.vval.v_list = &fc->l_varlist;
vim_memset(&fc->l_varlist, 0, sizeof(list_T)); memset(&fc->l_varlist, 0, sizeof(list_T));
fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT; fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT;
fc->l_varlist.lv_lock = VAR_FIXED; fc->l_varlist.lv_lock = VAR_FIXED;

View File

@ -11,6 +11,8 @@
* ex_docmd.c: functions for executing an Ex command line. * ex_docmd.c: functions for executing an Ex command line.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "ex_docmd.h" #include "ex_docmd.h"
#include "blowfish.h" #include "blowfish.h"
@ -590,7 +592,7 @@ int flags;
if (flags & DOCMD_EXCRESET) if (flags & DOCMD_EXCRESET)
save_dbg_stuff(&debug_saved); save_dbg_stuff(&debug_saved);
else else
vim_memset(&debug_saved, 0, 1); memset(&debug_saved, 0, 1);
initial_trylevel = trylevel; initial_trylevel = trylevel;
@ -1310,7 +1312,7 @@ void *cookie; /*argument for fgetline() */
cmdmod_T save_cmdmod; cmdmod_T save_cmdmod;
int ni; /* set when Not Implemented */ int ni; /* set when Not Implemented */
vim_memset(&ea, 0, sizeof(ea)); memset(&ea, 0, sizeof(ea));
ea.line1 = 1; ea.line1 = 1;
ea.line2 = 1; ea.line2 = 1;
++ex_nesting_level; ++ex_nesting_level;
@ -1329,7 +1331,7 @@ void *cookie; /*argument for fgetline() */
* recursive calls. * recursive calls.
*/ */
save_cmdmod = cmdmod; save_cmdmod = cmdmod;
vim_memset(&cmdmod, 0, sizeof(cmdmod)); memset(&cmdmod, 0, sizeof(cmdmod));
/* "#!anything" is handled like a comment. */ /* "#!anything" is handled like a comment. */
if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')
@ -5797,7 +5799,7 @@ handle_drop (
* Move to the first file. * Move to the first file.
*/ */
/* Fake up a minimal "next" command for do_argfile() */ /* Fake up a minimal "next" command for do_argfile() */
vim_memset(&ea, 0, sizeof(ea)); memset(&ea, 0, sizeof(ea));
ea.cmd = (char_u *)"next"; ea.cmd = (char_u *)"next";
do_argfile(&ea, 0); do_argfile(&ea, 0);
@ -6089,7 +6091,7 @@ void tabpage_new(void)
{ {
exarg_T ea; exarg_T ea;
vim_memset(&ea, 0, sizeof(ea)); memset(&ea, 0, sizeof(ea));
ea.cmdidx = CMD_tabnew; ea.cmdidx = CMD_tabnew;
ea.cmd = (char_u *)"tabn"; ea.cmd = (char_u *)"tabn";
ea.arg = (char_u *)""; ea.arg = (char_u *)"";

View File

@ -11,6 +11,8 @@
* ex_getln.c: Functions for entering and editing an Ex command line. * ex_getln.c: Functions for entering and editing an Ex command line.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "arabic.h" #include "arabic.h"
#include "ex_getln.h" #include "ex_getln.h"
@ -2331,7 +2333,7 @@ static int prev_ccline_used = FALSE;
static void save_cmdline(struct cmdline_info *ccp) static void save_cmdline(struct cmdline_info *ccp)
{ {
if (!prev_ccline_used) { if (!prev_ccline_used) {
vim_memset(&prev_ccline, 0, sizeof(struct cmdline_info)); memset(&prev_ccline, 0, sizeof(struct cmdline_info));
prev_ccline_used = TRUE; prev_ccline_used = TRUE;
} }
*ccp = prev_ccline; *ccp = prev_ccline;

View File

@ -44,6 +44,8 @@
* functions. * functions.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "file_search.h" #include "file_search.h"
#include "charset.h" #include "charset.h"
@ -278,7 +280,7 @@ vim_findfile_init (
search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T)); search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T));
if (search_ctx == NULL) if (search_ctx == NULL)
goto error_return; goto error_return;
vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T)); memset(search_ctx, 0, sizeof(ff_search_ctx_T));
} }
search_ctx->ffsc_find_what = find_what; search_ctx->ffsc_find_what = find_what;
search_ctx->ffsc_tagfile = tagfile; search_ctx->ffsc_tagfile = tagfile;

View File

@ -12,6 +12,8 @@
* fold.c: code for folding * fold.c: code for folding
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "fold.h" #include "fold.h"
#include "charset.h" #include "charset.h"
@ -1725,7 +1727,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi
level = foldinfo->fi_level; level = foldinfo->fi_level;
if (level > (int)sizeof(dashes) - 1) if (level > (int)sizeof(dashes) - 1)
level = (int)sizeof(dashes) - 1; level = (int)sizeof(dashes) - 1;
vim_memset(dashes, '-', (size_t)level); memset(dashes, '-', (size_t)level);
dashes[level] = NUL; dashes[level] = NUL;
set_vim_var_string(VV_FOLDDASHES, dashes, -1); set_vim_var_string(VV_FOLDDASHES, dashes, -1);
set_vim_var_nr(VV_FOLDLEVEL, (long)level); set_vim_var_nr(VV_FOLDLEVEL, (long)level);

View File

@ -2,6 +2,8 @@
/// ///
/// Functions for handling growing arrays. /// Functions for handling growing arrays.
#include <string.h>
#include "vim.h" #include "vim.h"
#include "ascii.h" #include "ascii.h"
#include "misc2.h" #include "misc2.h"
@ -77,7 +79,7 @@ int ga_grow(garray_T *gap, int n)
return FAIL; return FAIL;
} }
old_len = gap->ga_itemsize * gap->ga_maxlen; old_len = gap->ga_itemsize * gap->ga_maxlen;
vim_memset(pp + old_len, 0, new_len - old_len); memset(pp + old_len, 0, new_len - old_len);
gap->ga_maxlen = gap->ga_len + n; gap->ga_maxlen = gap->ga_len + n;
gap->ga_data = pp; gap->ga_data = pp;
} }

View File

@ -16,6 +16,8 @@
* mappings and abbreviations * mappings and abbreviations
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "getchar.h" #include "getchar.h"
#include "charset.h" #include "charset.h"
@ -3073,7 +3075,7 @@ static void map_free(mapblock_T **mpp)
static void validate_maphash(void) static void validate_maphash(void)
{ {
if (!maphash_valid) { if (!maphash_valid) {
vim_memset(maphash, 0, sizeof(maphash)); memset(maphash, 0, sizeof(maphash));
maphash_valid = TRUE; maphash_valid = TRUE;
} }
} }

View File

@ -11,6 +11,8 @@
* hardcopy.c: printing to paper * hardcopy.c: printing to paper
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "version_defs.h" #include "version_defs.h"
#include "hardcopy.h" #include "hardcopy.h"
@ -521,7 +523,7 @@ void ex_hardcopy(exarg_T *eap)
int page_line; int page_line;
int jobsplit; int jobsplit;
vim_memset(&settings, 0, sizeof(prt_settings_T)); memset(&settings, 0, sizeof(prt_settings_T));
settings.has_color = TRUE; settings.has_color = TRUE;
if (*eap->arg == '>') { if (*eap->arg == '>') {
@ -625,7 +627,7 @@ void ex_hardcopy(exarg_T *eap)
prt_pos_T page_prtpos; /* print position at page start */ prt_pos_T page_prtpos; /* print position at page start */
int side; int side;
vim_memset(&page_prtpos, 0, sizeof(prt_pos_T)); memset(&page_prtpos, 0, sizeof(prt_pos_T));
page_prtpos.file_line = eap->line1; page_prtpos.file_line = eap->line1;
prtpos = page_prtpos; prtpos = page_prtpos;
@ -1747,7 +1749,7 @@ static int prt_open_resource(struct prt_ps_resource_S *resource)
EMSG2(_("E624: Can't open file \"%s\""), resource->filename); EMSG2(_("E624: Can't open file \"%s\""), resource->filename);
return FALSE; return FALSE;
} }
vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN); memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN);
/* Parse first line to ensure valid resource file */ /* Parse first line to ensure valid resource file */
prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u), prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u),

View File

@ -18,6 +18,8 @@
/// of the entries is empty to keep the lookup efficient (at the cost of extra /// of the entries is empty to keep the lookup efficient (at the cost of extra
/// memory). /// memory).
#include <string.h>
#include "vim.h" #include "vim.h"
#include "hashtab.h" #include "hashtab.h"
#include "message.h" #include "message.h"
@ -35,7 +37,7 @@ static int hash_may_resize(hashtab_T *ht, int minitems);
void hash_init(hashtab_T *ht) void hash_init(hashtab_T *ht)
{ {
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray". // This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
vim_memset(ht, 0, sizeof(hashtab_T)); memset(ht, 0, sizeof(hashtab_T));
ht->ht_array = ht->ht_smallarray; ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1; ht->ht_mask = HT_INIT_SIZE - 1;
} }
@ -356,7 +358,7 @@ static int hash_may_resize(hashtab_T *ht, int minitems)
} }
oldarray = ht->ht_array; oldarray = ht->ht_array;
} }
vim_memset(newarray, 0, (size_t)(sizeof(hashitem_T) * newsize)); memset(newarray, 0, (size_t)(sizeof(hashitem_T) * newsize));
// Move all the items from the old array to the new one, placing them in // Move all the items from the old array to the new one, placing them in
// the right spot. The new array won't have any removed items, thus this // the right spot. The new array won't have any removed items, thus this

View File

@ -8,6 +8,8 @@
*/ */
#define EXTERN #define EXTERN
#include <string.h>
#include "vim.h" #include "vim.h"
#include "main.h" #include "main.h"
#include "blowfish.h" #include "blowfish.h"
@ -1493,7 +1495,7 @@ scripterror:
* copied, so that they can be changed. */ * copied, so that they can be changed. */
static void init_params(mparm_T *paramp, int argc, char **argv) static void init_params(mparm_T *paramp, int argc, char **argv)
{ {
vim_memset(paramp, 0, sizeof(*paramp)); memset(paramp, 0, sizeof(*paramp));
paramp->argc = argc; paramp->argc = argc;
paramp->argv = argv; paramp->argv = argv;
paramp->want_full_screen = TRUE; paramp->want_full_screen = TRUE;

View File

@ -32,6 +32,8 @@
* file is opened. * file is opened.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "memfile.h" #include "memfile.h"
#include "fileio.h" #include "fileio.h"
@ -372,7 +374,7 @@ bhdr_T *mf_new(memfile_T *mfp, int negative, int page_count)
* Init the data to all zero, to avoid reading uninitialized data. * Init the data to all zero, to avoid reading uninitialized data.
* This also avoids that the passwd file ends up in the swap file! * This also avoids that the passwd file ends up in the swap file!
*/ */
(void)vim_memset((char *)(hp->bh_data), 0, (void)memset((char *)(hp->bh_data), 0,
(size_t)mfp->mf_page_size * page_count); (size_t)mfp->mf_page_size * page_count);
return hp; return hp;
@ -1151,7 +1153,7 @@ mf_do_open (
*/ */
static void mf_hash_init(mf_hashtab_T *mht) static void mf_hash_init(mf_hashtab_T *mht)
{ {
vim_memset(mht, 0, sizeof(mf_hashtab_T)); memset(mht, 0, sizeof(mf_hashtab_T));
mht->mht_buckets = mht->mht_small_buckets; mht->mht_buckets = mht->mht_small_buckets;
mht->mht_mask = MHT_INIT_SIZE - 1; mht->mht_mask = MHT_INIT_SIZE - 1;
} }
@ -1284,7 +1286,7 @@ static int mf_hash_grow(mf_hashtab_T *mht)
* a power of two. * a power of two.
*/ */
vim_memset(tails, 0, sizeof(tails)); memset(tails, 0, sizeof(tails));
for (mhi = mht->mht_buckets[i]; mhi != NULL; mhi = mhi->mhi_next) { for (mhi = mht->mht_buckets[i]; mhi != NULL; mhi = mhi->mhi_next) {
j = (mhi->mhi_key >> shift) & (MHT_GROWTH_FACTOR - 1); j = (mhi->mhi_key >> shift) & (MHT_GROWTH_FACTOR - 1);

View File

@ -42,6 +42,8 @@
* mf_get(). * mf_get().
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "memline.h" #include "memline.h"
#include "blowfish.h" #include "blowfish.h"
@ -4217,7 +4219,7 @@ char_u *ml_encrypt_data(memfile_T *mfp, char_u *data, off_t offset, unsigned siz
/* Clear the gap. */ /* Clear the gap. */
if (head_end < text_start) if (head_end < text_start)
vim_memset(new_data + (head_end - data), 0, text_start - head_end); memset(new_data + (head_end - data), 0, text_start - head_end);
return new_data; return new_data;
} }

View File

@ -13,6 +13,8 @@
#define MESSAGE_FILE /* don't include prototype for smsg() */ #define MESSAGE_FILE /* don't include prototype for smsg() */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "message.h" #include "message.h"
#include "charset.h" #include "charset.h"
@ -3861,7 +3863,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m - str_l; size_t avail = str_m - str_l;
vim_memset(str + str_l, zero_padding ? '0' : ' ', memset(str + str_l, zero_padding ? '0' : ' ',
(size_t)pn > avail ? avail (size_t)pn > avail ? avail
: (size_t)pn); : (size_t)pn);
} }
@ -3898,7 +3900,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m-str_l; size_t avail = str_m-str_l;
vim_memset(str + str_l, '0', memset(str + str_l, '0',
(size_t)zn > avail ? avail (size_t)zn > avail ? avail
: (size_t)zn); : (size_t)zn);
} }
@ -3933,7 +3935,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
if (str_l < str_m) { if (str_l < str_m) {
size_t avail = str_m - str_l; size_t avail = str_m - str_l;
vim_memset(str + str_l, ' ', memset(str + str_l, ' ',
(size_t)pn > avail ? avail (size_t)pn > avail ? avail
: (size_t)pn); : (size_t)pn);
} }

View File

@ -10,6 +10,8 @@
/* /*
* misc2.c: Various functions. * misc2.c: Various functions.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "misc2.h" #include "misc2.h"
#include "file_search.h" #include "file_search.h"
@ -716,7 +718,7 @@ char_u *alloc_clear(unsigned size)
p = lalloc((long_u)size, TRUE); p = lalloc((long_u)size, TRUE);
if (p != NULL) if (p != NULL)
(void)vim_memset(p, 0, (size_t)size); (void)memset(p, 0, (size_t)size);
return p; return p;
} }
@ -745,7 +747,7 @@ char_u *lalloc_clear(long_u size, int message)
p = (lalloc(size, message)); p = (lalloc(size, message));
if (p != NULL) if (p != NULL)
(void)vim_memset(p, 0, (size_t)size); (void)memset(p, 0, (size_t)size);
return p; return p;
} }
@ -1406,20 +1408,6 @@ void vim_free(void *x)
} }
} }
#ifndef HAVE_MEMSET
void * vim_memset(ptr, c, size)
void *ptr;
int c;
size_t size;
{
char *p = ptr;
while (size-- > 0)
*p++ = c;
return ptr;
}
#endif
#ifdef VIM_MEMCMP #ifdef VIM_MEMCMP
/* /*
* Return zero when "b1" and "b2" are the same for "len" bytes. * Return zero when "b1" and "b2" are the same for "len" bytes.

View File

@ -12,6 +12,8 @@
* the operators. * the operators.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "normal.h" #include "normal.h"
#include "buffer.h" #include "buffer.h"
@ -522,7 +524,7 @@ normal_cmd (
int idx; int idx;
int set_prevcount = FALSE; int set_prevcount = FALSE;
vim_memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */ memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */
ca.oap = oap; ca.oap = oap;
/* Use a count remembered from before entering an operator. After typing /* Use a count remembered from before entering an operator. After typing
@ -4339,7 +4341,7 @@ void do_nv_ident(int c1, int c2)
cmdarg_T ca; cmdarg_T ca;
clear_oparg(&oa); clear_oparg(&oa);
vim_memset(&ca, 0, sizeof(ca)); memset(&ca, 0, sizeof(ca));
ca.oap = &oa; ca.oap = &oa;
ca.cmdchar = c1; ca.cmdchar = c1;
ca.nchar = c2; ca.nchar = c2;

View File

@ -12,6 +12,8 @@
* op_change, op_yank, do_put, do_join * op_change, op_yank, do_put, do_join
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "ops.h" #include "ops.h"
#include "buffer.h" #include "buffer.h"
@ -382,7 +384,7 @@ static void shift_block(oparg_T *oap, int amount)
newp = alloc_check((unsigned)(bd.textcol + i + j + len)); newp = alloc_check((unsigned)(bd.textcol + i + j + len));
if (newp == NULL) if (newp == NULL)
return; return;
vim_memset(newp, NUL, (size_t)(bd.textcol + i + j + len)); memset(newp, NUL, (size_t)(bd.textcol + i + j + len));
mch_memmove(newp, oldp, (size_t)bd.textcol); mch_memmove(newp, oldp, (size_t)bd.textcol);
copy_chars(newp + bd.textcol, (size_t)i, TAB); copy_chars(newp + bd.textcol, (size_t)i, TAB);
copy_spaces(newp + bd.textcol + i, (size_t)j); copy_spaces(newp + bd.textcol + i, (size_t)j);
@ -1778,7 +1780,7 @@ int op_replace(oparg_T *oap, int c)
newp = alloc_check((unsigned)oldlen + 1 + n); newp = alloc_check((unsigned)oldlen + 1 + n);
if (newp == NULL) if (newp == NULL)
continue; continue;
vim_memset(newp, NUL, (size_t)(oldlen + 1 + n)); memset(newp, NUL, (size_t)(oldlen + 1 + n));
/* copy up to deleted part */ /* copy up to deleted part */
mch_memmove(newp, oldp, (size_t)bd.textcol); mch_memmove(newp, oldp, (size_t)bd.textcol);
oldp += bd.textcol + bd.textlen; oldp += bd.textcol + bd.textlen;
@ -4985,7 +4987,7 @@ str_to_reg (
void clear_oparg(oparg_T *oap) void clear_oparg(oparg_T *oap)
{ {
vim_memset(oap, 0, sizeof(oparg_T)); memset(oap, 0, sizeof(oparg_T));
} }
static long line_count_info(char_u *line, long *wc, long *cc, static long line_count_info(char_u *line, long *wc, long *cc,

View File

@ -11,6 +11,8 @@
* quickfix.c: functions for quickfix mode, using a file with error messages * quickfix.c: functions for quickfix mode, using a file with error messages
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "quickfix.h" #include "quickfix.h"
#include "buffer.h" #include "buffer.h"
@ -857,7 +859,7 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title)
qi->qf_curlist = LISTCOUNT - 1; qi->qf_curlist = LISTCOUNT - 1;
} else } else
qi->qf_curlist = qi->qf_listcount++; qi->qf_curlist = qi->qf_listcount++;
vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
if (qf_title != NULL) { if (qf_title != NULL) {
char_u *p = alloc((int)STRLEN(qf_title) + 2); char_u *p = alloc((int)STRLEN(qf_title) + 2);
@ -984,7 +986,7 @@ static qf_info_T *ll_new_list(void)
qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
if (qi != NULL) { if (qi != NULL) {
vim_memset(qi, 0, (size_t)(sizeof(qf_info_T))); memset(qi, 0, (size_t)(sizeof(qf_info_T)));
qi->qf_refcount++; qi->qf_refcount++;
} }

View File

@ -44,6 +44,8 @@
/* #undef REGEXP_DEBUG */ /* #undef REGEXP_DEBUG */
/* #define REGEXP_DEBUG */ /* #define REGEXP_DEBUG */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "regexp.h" #include "regexp.h"
#include "charset.h" #include "charset.h"
@ -1334,7 +1336,7 @@ regcomp_start (
num_complex_braces = 0; num_complex_braces = 0;
regnpar = 1; regnpar = 1;
vim_memset(had_endbrace, 0, sizeof(had_endbrace)); memset(had_endbrace, 0, sizeof(had_endbrace));
regnzpar = 1; regnzpar = 1;
re_has_z = 0; re_has_z = 0;
regsize = 0L; regsize = 0L;
@ -5515,11 +5517,11 @@ static void cleanup_subexpr(void)
if (need_clear_subexpr) { if (need_clear_subexpr) {
if (REG_MULTI) { if (REG_MULTI) {
/* Use 0xff to set lnum to -1 */ /* Use 0xff to set lnum to -1 */
vim_memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP);
vim_memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP);
} else { } else {
vim_memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP); memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP);
vim_memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP); memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP);
} }
need_clear_subexpr = FALSE; need_clear_subexpr = FALSE;
} }
@ -5530,11 +5532,11 @@ static void cleanup_zsubexpr(void)
if (need_clear_zsubexpr) { if (need_clear_zsubexpr) {
if (REG_MULTI) { if (REG_MULTI) {
/* Use 0xff to set lnum to -1 */ /* Use 0xff to set lnum to -1 */
vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP); memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP); memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
} else { } else {
vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP); memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP);
vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP); memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP);
} }
need_clear_zsubexpr = FALSE; need_clear_zsubexpr = FALSE;
} }

View File

@ -3544,10 +3544,10 @@ static void clear_sub(regsub_T *sub)
{ {
if (REG_MULTI) if (REG_MULTI)
/* Use 0xff to set lnum to -1 */ /* Use 0xff to set lnum to -1 */
vim_memset(sub->list.multi, 0xff, memset(sub->list.multi, 0xff,
sizeof(struct multipos) * nfa_nsubexpr); sizeof(struct multipos) * nfa_nsubexpr);
else else
vim_memset(sub->list.line, 0, sizeof(struct linepos) * nfa_nsubexpr); memset(sub->list.line, 0, sizeof(struct linepos) * nfa_nsubexpr);
sub->in_use = 0; sub->in_use = 0;
} }

View File

@ -87,6 +87,8 @@
* update_screen() called to redraw. * update_screen() called to redraw.
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "arabic.h" #include "arabic.h"
#include "screen.h" #include "screen.h"
@ -2034,7 +2036,7 @@ static void copy_text_attr(int off, char_u *buf, int len, int attr)
mch_memmove(ScreenLines + off, buf, (size_t)len); mch_memmove(ScreenLines + off, buf, (size_t)len);
if (enc_utf8) if (enc_utf8)
vim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len); memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len);
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
ScreenAttrs[off + i] = attr; ScreenAttrs[off + i] = attr;
} }
@ -6116,7 +6118,7 @@ retry:
new_ScreenLines = (schar_T *)lalloc((long_u)( new_ScreenLines = (schar_T *)lalloc((long_u)(
(Rows + 1) * Columns * sizeof(schar_T)), FALSE); (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO); memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO);
if (enc_utf8) { if (enc_utf8) {
new_ScreenLinesUC = (u8char_T *)lalloc((long_u)( new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
(Rows + 1) * Columns * sizeof(u8char_T)), FALSE); (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
@ -6197,20 +6199,20 @@ give_up:
* executing an external command, for the GUI). * executing an external command, for the GUI).
*/ */
if (!doclear) { if (!doclear) {
(void)vim_memset(new_ScreenLines + new_row * Columns, (void)memset(new_ScreenLines + new_row * Columns,
' ', (size_t)Columns * sizeof(schar_T)); ' ', (size_t)Columns * sizeof(schar_T));
if (enc_utf8) { if (enc_utf8) {
(void)vim_memset(new_ScreenLinesUC + new_row * Columns, (void)memset(new_ScreenLinesUC + new_row * Columns,
0, (size_t)Columns * sizeof(u8char_T)); 0, (size_t)Columns * sizeof(u8char_T));
for (i = 0; i < p_mco; ++i) for (i = 0; i < p_mco; ++i)
(void)vim_memset(new_ScreenLinesC[i] (void)memset(new_ScreenLinesC[i]
+ new_row * Columns, + new_row * Columns,
0, (size_t)Columns * sizeof(u8char_T)); 0, (size_t)Columns * sizeof(u8char_T));
} }
if (enc_dbcs == DBCS_JPNU) if (enc_dbcs == DBCS_JPNU)
(void)vim_memset(new_ScreenLines2 + new_row * Columns, (void)memset(new_ScreenLines2 + new_row * Columns,
0, (size_t)Columns * sizeof(schar_T)); 0, (size_t)Columns * sizeof(schar_T));
(void)vim_memset(new_ScreenAttrs + new_row * Columns, (void)memset(new_ScreenAttrs + new_row * Columns,
0, (size_t)Columns * sizeof(sattr_T)); 0, (size_t)Columns * sizeof(sattr_T));
old_row = new_row + (screen_Rows - Rows); old_row = new_row + (screen_Rows - Rows);
if (old_row >= 0 && ScreenLines != NULL) { if (old_row >= 0 && ScreenLines != NULL) {
@ -6360,11 +6362,11 @@ static void screenclear2(void)
*/ */
static void lineclear(unsigned off, int width) static void lineclear(unsigned off, int width)
{ {
(void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T)); (void)memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T));
if (enc_utf8) if (enc_utf8)
(void)vim_memset(ScreenLinesUC + off, 0, (void)memset(ScreenLinesUC + off, 0,
(size_t)width * sizeof(u8char_T)); (size_t)width * sizeof(u8char_T));
(void)vim_memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T)); (void)memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T));
} }
/* /*
@ -6373,7 +6375,7 @@ static void lineclear(unsigned off, int width)
*/ */
static void lineinvalid(unsigned off, int width) static void lineinvalid(unsigned off, int width)
{ {
(void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T)); (void)memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T));
} }
/* /*

View File

@ -13,6 +13,8 @@
/// 2. sha2_seed() generates a random header. /// 2. sha2_seed() generates a random header.
/// sha256_self_test() is implicitly called once. /// sha256_self_test() is implicitly called once.
#include <string.h>
#include "vim.h" #include "vim.h"
#include "sha256.h" #include "sha256.h"
@ -342,7 +344,7 @@ int sha256_self_test(void)
STRCPY(output, hexit); STRCPY(output, hexit);
} else { } else {
sha256_start(&ctx); sha256_start(&ctx);
vim_memset(buf, 'a', 1000); memset(buf, 'a', 1000);
for (j = 0; j < 1000; j++) { for (j = 0; j < 1000; j++) {
sha256_update(&ctx, (char_u *) buf, 1000); sha256_update(&ctx, (char_u *) buf, 1000);

View File

@ -297,6 +297,8 @@
* few bytes as possible, see offset2bytes()) * few bytes as possible, see offset2bytes())
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "spell.h" #include "spell.h"
#include "buffer.h" #include "buffer.h"
@ -1047,7 +1049,7 @@ spell_check (
if (wp->w_s->b_langp.ga_len == 0) if (wp->w_s->b_langp.ga_len == 0)
return 1; return 1;
vim_memset(&mi, 0, sizeof(matchinf_T)); memset(&mi, 0, sizeof(matchinf_T));
/* A number is always OK. Also skip hexadecimal numbers 0xFF99 and /* A number is always OK. Also skip hexadecimal numbers 0xFF99 and
* 0X99FF. But always do check spelling to find "3GPP" and "11 * 0X99FF. But always do check spelling to find "3GPP" and "11
@ -2274,7 +2276,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen)
* concatenate. */ * concatenate. */
n = (int)(p - line) + 1; n = (int)(p - line) + 1;
if (n < maxlen - 1) { if (n < maxlen - 1) {
vim_memset(buf, ' ', n); memset(buf, ' ', n);
vim_strncpy(buf + n, p, maxlen - 1 - n); vim_strncpy(buf + n, p, maxlen - 1 - n);
} }
} }
@ -3536,7 +3538,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to)
ga_init2(gap, sizeof(int *), 1); ga_init2(gap, sizeof(int *), 1);
if (ga_grow(gap, 256) == FAIL) if (ga_grow(gap, 256) == FAIL)
return SP_OTHERERROR; return SP_OTHERERROR;
vim_memset(gap->ga_data, 0, sizeof(int *) * 256); memset(gap->ga_data, 0, sizeof(int *) * 256);
gap->ga_len = 256; gap->ga_len = 256;
/* First count the number of items for each list. Temporarily use /* First count the number of items for each list. Temporarily use
@ -3562,7 +3564,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to)
/* Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal /* Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal
* list. */ * list. */
vim_memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256); memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256);
for (p = from, s = to; *p != NUL && *s != NUL; ) { for (p = from, s = to; *p != NUL && *s != NUL; ) {
c = mb_cptr2char_adv(&p); c = mb_cptr2char_adv(&p);
i = mb_cptr2char_adv(&s); i = mb_cptr2char_adv(&s);
@ -4108,7 +4110,7 @@ theend:
*/ */
static void clear_midword(win_T *wp) static void clear_midword(win_T *wp)
{ {
vim_memset(wp->w_s->b_spell_ismw, 0, 256); memset(wp->w_s->b_spell_ismw, 0, 256);
vim_free(wp->w_s->b_spell_ismw_mb); vim_free(wp->w_s->b_spell_ismw_mb);
wp->w_s->b_spell_ismw_mb = NULL; wp->w_s->b_spell_ismw_mb = NULL;
} }
@ -6913,7 +6915,7 @@ static wordnode_T *get_wordnode(spellinfo_T *spin)
else { else {
n = spin->si_first_free; n = spin->si_first_free;
spin->si_first_free = n->wn_child; spin->si_first_free = n->wn_child;
vim_memset(n, 0, sizeof(wordnode_T)); memset(n, 0, sizeof(wordnode_T));
--spin->si_free_count; --spin->si_free_count;
} }
#ifdef SPELL_PRINTTREE #ifdef SPELL_PRINTTREE
@ -8167,7 +8169,7 @@ mkspell (
int error = FALSE; int error = FALSE;
spellinfo_T spin; spellinfo_T spin;
vim_memset(&spin, 0, sizeof(spin)); memset(&spin, 0, sizeof(spin));
spin.si_verbose = !added_word; spin.si_verbose = !added_word;
spin.si_ascii = ascii; spin.si_ascii = ascii;
spin.si_followup = TRUE; spin.si_followup = TRUE;
@ -8641,8 +8643,8 @@ static void clear_spell_chartab(spelltab_T *sp)
int i; int i;
/* Init everything to FALSE. */ /* Init everything to FALSE. */
vim_memset(sp->st_isw, FALSE, sizeof(sp->st_isw)); memset(sp->st_isw, FALSE, sizeof(sp->st_isw));
vim_memset(sp->st_isu, FALSE, sizeof(sp->st_isu)); memset(sp->st_isu, FALSE, sizeof(sp->st_isu));
for (i = 0; i < 256; ++i) { for (i = 0; i < 256; ++i) {
sp->st_fold[i] = i; sp->st_fold[i] = i;
sp->st_upper[i] = i; sp->st_upper[i] = i;
@ -9471,7 +9473,7 @@ spell_find_suggest (
/* /*
* Set the info in "*su". * Set the info in "*su".
*/ */
vim_memset(su, 0, sizeof(suginfo_T)); memset(su, 0, sizeof(suginfo_T));
ga_init2(&su->su_ga, (int)sizeof(suggest_T), 10); ga_init2(&su->su_ga, (int)sizeof(suggest_T), 10);
ga_init2(&su->su_sga, (int)sizeof(suggest_T), 10); ga_init2(&su->su_sga, (int)sizeof(suggest_T), 10);
if (*badptr == NUL) if (*badptr == NUL)
@ -10150,7 +10152,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou
*/ */
depth = 0; depth = 0;
sp = &stack[0]; sp = &stack[0];
vim_memset(sp, 0, sizeof(trystate_T)); memset(sp, 0, sizeof(trystate_T));
sp->ts_curi = 1; sp->ts_curi = 1;
if (soundfold) { if (soundfold) {

View File

@ -11,6 +11,8 @@
* syntax.c: code for syntax highlighting * syntax.c: code for syntax highlighting
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "syntax.h" #include "syntax.h"
#include "charset.h" #include "charset.h"
@ -2583,7 +2585,7 @@ static int push_current_state(int idx)
{ {
if (ga_grow(&current_state, 1) == FAIL) if (ga_grow(&current_state, 1) == FAIL)
return FAIL; return FAIL;
vim_memset(&CUR_STATE(current_state.ga_len), 0, sizeof(stateitem_T)); memset(&CUR_STATE(current_state.ga_len), 0, sizeof(stateitem_T));
CUR_STATE(current_state.ga_len).si_idx = idx; CUR_STATE(current_state.ga_len).si_idx = idx;
++current_state.ga_len; ++current_state.ga_len;
return OK; return OK;
@ -4375,7 +4377,7 @@ syn_cmd_match (
/* get the pattern. */ /* get the pattern. */
init_syn_patterns(); init_syn_patterns();
vim_memset(&item, 0, sizeof(item)); memset(&item, 0, sizeof(item));
rest = get_syn_pattern(rest, &item); rest = get_syn_pattern(rest, &item);
if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL))
syn_opt_arg.flags |= HL_HAS_EOL; syn_opt_arg.flags |= HL_HAS_EOL;
@ -4898,7 +4900,7 @@ static int syn_add_cluster(char_u *name)
return 0; return 0;
} }
vim_memset(&(SYN_CLSTR(curwin->w_s)[len]), 0, sizeof(syn_cluster_T)); memset(&(SYN_CLSTR(curwin->w_s)[len]), 0, sizeof(syn_cluster_T));
SYN_CLSTR(curwin->w_s)[len].scl_name = name; SYN_CLSTR(curwin->w_s)[len].scl_name = name;
SYN_CLSTR(curwin->w_s)[len].scl_name_u = vim_strsave_up(name); SYN_CLSTR(curwin->w_s)[len].scl_name_u = vim_strsave_up(name);
SYN_CLSTR(curwin->w_s)[len].scl_list = NULL; SYN_CLSTR(curwin->w_s)[len].scl_list = NULL;
@ -6986,7 +6988,7 @@ static int get_attr_entry(garray_T *table, attrentry_T *aep)
return 0; return 0;
taep = &(((attrentry_T *)table->ga_data)[table->ga_len]); taep = &(((attrentry_T *)table->ga_data)[table->ga_len]);
vim_memset(taep, 0, sizeof(attrentry_T)); memset(taep, 0, sizeof(attrentry_T));
taep->ae_attr = aep->ae_attr; taep->ae_attr = aep->ae_attr;
if (table == &term_attr_table) { if (table == &term_attr_table) {
if (aep->ae_u.term.start == NULL) if (aep->ae_u.term.start == NULL)
@ -7048,7 +7050,7 @@ int hl_combine_attr(int char_attr, int prim_attr)
if (char_aep != NULL) if (char_aep != NULL)
new_en = *char_aep; new_en = *char_aep;
else { else {
vim_memset(&new_en, 0, sizeof(new_en)); memset(&new_en, 0, sizeof(new_en));
if (char_attr <= HL_ALL) if (char_attr <= HL_ALL)
new_en.ae_attr = char_attr; new_en.ae_attr = char_attr;
} }
@ -7073,7 +7075,7 @@ int hl_combine_attr(int char_attr, int prim_attr)
if (char_aep != NULL) if (char_aep != NULL)
new_en = *char_aep; new_en = *char_aep;
else { else {
vim_memset(&new_en, 0, sizeof(new_en)); memset(&new_en, 0, sizeof(new_en));
if (char_attr <= HL_ALL) if (char_attr <= HL_ALL)
new_en.ae_attr = char_attr; new_en.ae_attr = char_attr;
} }
@ -7535,7 +7537,7 @@ static int syn_add_group(char_u *name)
return 0; return 0;
} }
vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group));
HL_TABLE()[highlight_ga.ga_len].sg_name = name; HL_TABLE()[highlight_ga.ga_len].sg_name = name;
HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name);
++highlight_ga.ga_len; ++highlight_ga.ga_len;
@ -7717,7 +7719,7 @@ int highlight_changed(void)
return FAIL; return FAIL;
hlcnt = highlight_ga.ga_len; hlcnt = highlight_ga.ga_len;
if (id_S == 0) { /* Make sure id_S is always valid to simplify code below */ if (id_S == 0) { /* Make sure id_S is always valid to simplify code below */
vim_memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group)); memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group));
HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S]; HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S];
id_S = hlcnt + 10; id_S = hlcnt + 10;
} }
@ -7732,7 +7734,7 @@ int highlight_changed(void)
highlight_user[i] = syn_id2attr(id); highlight_user[i] = syn_id2attr(id);
if (id_SNC == 0) { if (id_SNC == 0) {
vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group)); memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group));
hlt[hlcnt + i].sg_term = highlight_attr[HLF_SNC]; hlt[hlcnt + i].sg_term = highlight_attr[HLF_SNC];
hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC]; hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC];
hlt[hlcnt + i].sg_gui = highlight_attr[HLF_SNC]; hlt[hlcnt + i].sg_gui = highlight_attr[HLF_SNC];

View File

@ -11,6 +11,8 @@
* Code to handle tags and the tag stack * Code to handle tags and the tag stack
*/ */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "tag.h" #include "tag.h"
#include "buffer.h" #include "buffer.h"
@ -1239,7 +1241,7 @@ find_tags (
/* This is only to avoid a compiler warning for using search_info /* This is only to avoid a compiler warning for using search_info
* uninitialised. */ * uninitialised. */
vim_memset(&search_info, 0, (size_t)1); memset(&search_info, 0, (size_t)1);
/* /*
* When finding a specified number of matches, first try with matching * When finding a specified number of matches, first try with matching
@ -2087,7 +2089,7 @@ get_tagfname (
char_u *r_ptr; char_u *r_ptr;
if (first) if (first)
vim_memset(tnp, 0, sizeof(tagname_T)); memset(tnp, 0, sizeof(tagname_T));
if (curbuf->b_help) { if (curbuf->b_help) {
/* /*

View File

@ -81,6 +81,8 @@
#define UH_MAGIC 0x18dade /* value for uh_magic when in use */ #define UH_MAGIC 0x18dade /* value for uh_magic when in use */
#define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */
#include <string.h>
#include "vim.h" #include "vim.h"
#include "undo.h" #include "undo.h"
#include "edit.h" #include "edit.h"
@ -579,7 +581,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload)
uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T)); uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T));
if (uep == NULL) if (uep == NULL)
goto nomem; goto nomem;
vim_memset(uep, 0, sizeof(u_entry_T)); memset(uep, 0, sizeof(u_entry_T));
#ifdef U_DEBUG #ifdef U_DEBUG
uep->ue_magic = UE_MAGIC; uep->ue_magic = UE_MAGIC;
#endif #endif
@ -919,7 +921,7 @@ static u_header_T *unserialize_uhp(FILE *fp, char_u *file_name)
uhp = (u_header_T *)U_ALLOC_LINE(sizeof(u_header_T)); uhp = (u_header_T *)U_ALLOC_LINE(sizeof(u_header_T));
if (uhp == NULL) if (uhp == NULL)
return NULL; return NULL;
vim_memset(uhp, 0, sizeof(u_header_T)); memset(uhp, 0, sizeof(u_header_T));
#ifdef U_DEBUG #ifdef U_DEBUG
uhp->uh_magic = UH_MAGIC; uhp->uh_magic = UH_MAGIC;
#endif #endif
@ -1017,7 +1019,7 @@ static u_entry_T *unserialize_uep(FILE *fp, int *error, char_u *file_name)
uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T)); uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T));
if (uep == NULL) if (uep == NULL)
return NULL; return NULL;
vim_memset(uep, 0, sizeof(u_entry_T)); memset(uep, 0, sizeof(u_entry_T));
#ifdef U_DEBUG #ifdef U_DEBUG
uep->ue_magic = UE_MAGIC; uep->ue_magic = UE_MAGIC;
#endif #endif
@ -1031,7 +1033,7 @@ static u_entry_T *unserialize_uep(FILE *fp, int *error, char_u *file_name)
*error = TRUE; *error = TRUE;
return uep; return uep;
} }
vim_memset(array, 0, sizeof(char_u *) * uep->ue_size); memset(array, 0, sizeof(char_u *) * uep->ue_size);
} else } else
array = NULL; array = NULL;
uep->ue_array = array; uep->ue_array = array;

View File

@ -1163,12 +1163,6 @@ void mch_memmove(void *, void *, size_t);
#define fnamencmp(x, y, n) vim_fnamencmp((char_u *)(x), (char_u *)(y), \ #define fnamencmp(x, y, n) vim_fnamencmp((char_u *)(x), (char_u *)(y), \
(size_t)(n)) (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
#ifdef HAVE_MEMCMP #ifdef HAVE_MEMCMP
# define vim_memcmp(p1, p2, len) memcmp((p1), (p2), (len)) # define vim_memcmp(p1, p2, len) memcmp((p1), (p2), (len))
#else #else