diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-03-24 20:30:14 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-25 18:57:02 -0300 |
commit | ed3e9d51ac2fd2a24d244796dd9cebfe0a19bc6d (patch) | |
tree | ecb1f753dd0fad9889aca15a083c7c99c1407ba7 | |
parent | 68bc6bce2923f049f84d919aea24600f18139a46 (diff) | |
download | rneovim-ed3e9d51ac2fd2a24d244796dd9cebfe0a19bc6d.tar.gz rneovim-ed3e9d51ac2fd2a24d244796dd9cebfe0a19bc6d.tar.bz2 rneovim-ed3e9d51ac2fd2a24d244796dd9cebfe0a19bc6d.zip |
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'
-rw-r--r-- | src/blowfish.c | 4 | ||||
-rw-r--r-- | src/charset.c | 4 | ||||
-rw-r--r-- | src/edit.c | 4 | ||||
-rw-r--r-- | src/eval.c | 12 | ||||
-rw-r--r-- | src/ex_docmd.c | 12 | ||||
-rw-r--r-- | src/ex_getln.c | 4 | ||||
-rw-r--r-- | src/file_search.c | 4 | ||||
-rw-r--r-- | src/fold.c | 4 | ||||
-rw-r--r-- | src/garray.c | 4 | ||||
-rw-r--r-- | src/getchar.c | 4 | ||||
-rw-r--r-- | src/hardcopy.c | 8 | ||||
-rw-r--r-- | src/hashtab.c | 6 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/memfile.c | 8 | ||||
-rw-r--r-- | src/memline.c | 4 | ||||
-rw-r--r-- | src/message.c | 8 | ||||
-rw-r--r-- | src/misc2.c | 20 | ||||
-rw-r--r-- | src/normal.c | 6 | ||||
-rw-r--r-- | src/ops.c | 8 | ||||
-rw-r--r-- | src/quickfix.c | 6 | ||||
-rw-r--r-- | src/regexp.c | 20 | ||||
-rw-r--r-- | src/regexp_nfa.c | 4 | ||||
-rw-r--r-- | src/screen.c | 24 | ||||
-rw-r--r-- | src/sha256.c | 4 | ||||
-rw-r--r-- | src/spell.c | 24 | ||||
-rw-r--r-- | src/syntax.c | 20 | ||||
-rw-r--r-- | src/tag.c | 6 | ||||
-rw-r--r-- | src/undo.c | 10 | ||||
-rw-r--r-- | src/vim.h | 6 |
29 files changed, 143 insertions, 109 deletions
diff --git a/src/blowfish.c b/src/blowfish.c index 77b2f43c95..55c702cf31 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -11,6 +11,8 @@ * Based on http://www.schneier.com/blowfish.html by Bruce Schneier. */ +#include <string.h> + #include "vim.h" #include "blowfish.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) { randbyte_offset = update_offset = 0; - vim_memset(ofb_buffer, 0, BF_OFB_LEN); + memset(ofb_buffer, 0, BF_OFB_LEN); if (iv_len > 0) { int mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN; diff --git a/src/charset.c b/src/charset.c index 7d176ec092..034aebc30f 100644 --- a/src/charset.c +++ b/src/charset.c @@ -2,6 +2,8 @@ /// /// Code related to character sets. +#include <string.h> + #include "vim.h" #include "charset.h" #include "farsi.h" @@ -129,7 +131,7 @@ int buf_init_chartab(buf_T *buf, int global) } // 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) { for (c = 0; c < 256; ++c) { diff --git a/src/edit.c b/src/edit.c index f3a393a9a4..f081f9a219 100644 --- a/src/edit.c +++ b/src/edit.c @@ -11,6 +11,8 @@ * edit.c: functions for Insert mode */ +#include <string.h> + #include "vim.h" #include "edit.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"); } else { word = get_tv_string_chk(tv); - vim_memset(cptext, 0, sizeof(cptext)); + memset(cptext, 0, sizeof(cptext)); } if (word == NULL || (!aempty && *word == NUL)) return FAIL; diff --git a/src/eval.c b/src/eval.c index 140fe684ea..fdf1032484 100644 --- a/src/eval.c +++ b/src/eval.c @@ -11,6 +11,8 @@ * eval.c: Expression evaluation. */ +#include <string.h> + #include "vim.h" #include "eval.h" #include "buffer.h" @@ -2333,7 +2335,7 @@ get_lval ( int quiet = flags & GLV_QUIET; /* Clear everything in "lp". */ - vim_memset(lp, 0, sizeof(lval_T)); + memset(lp, 0, sizeof(lval_T)); if (skip) { /* 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 */ 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 (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) { 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; if (fdp != NULL) - vim_memset(fdp, 0, sizeof(funcdict_T)); + memset(fdp, 0, sizeof(funcdict_T)); start = *pp; /* 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_lock = VAR_FIXED; 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_lock = VAR_FIXED; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 75ccd4f952..87019dc749 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -11,6 +11,8 @@ * ex_docmd.c: functions for executing an Ex command line. */ +#include <string.h> + #include "vim.h" #include "ex_docmd.h" #include "blowfish.h" @@ -590,7 +592,7 @@ int flags; if (flags & DOCMD_EXCRESET) save_dbg_stuff(&debug_saved); else - vim_memset(&debug_saved, 0, 1); + memset(&debug_saved, 0, 1); initial_trylevel = trylevel; @@ -1310,7 +1312,7 @@ void *cookie; /*argument for fgetline() */ cmdmod_T save_cmdmod; int ni; /* set when Not Implemented */ - vim_memset(&ea, 0, sizeof(ea)); + memset(&ea, 0, sizeof(ea)); ea.line1 = 1; ea.line2 = 1; ++ex_nesting_level; @@ -1329,7 +1331,7 @@ void *cookie; /*argument for fgetline() */ * recursive calls. */ save_cmdmod = cmdmod; - vim_memset(&cmdmod, 0, sizeof(cmdmod)); + memset(&cmdmod, 0, sizeof(cmdmod)); /* "#!anything" is handled like a comment. */ if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') @@ -5797,7 +5799,7 @@ handle_drop ( * Move to the first file. */ /* 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"; do_argfile(&ea, 0); @@ -6089,7 +6091,7 @@ void tabpage_new(void) { exarg_T ea; - vim_memset(&ea, 0, sizeof(ea)); + memset(&ea, 0, sizeof(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 7008586663..03631eaabc 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -11,6 +11,8 @@ * ex_getln.c: Functions for entering and editing an Ex command line. */ +#include <string.h> + #include "vim.h" #include "arabic.h" #include "ex_getln.h" @@ -2331,7 +2333,7 @@ static int prev_ccline_used = FALSE; static void save_cmdline(struct cmdline_info *ccp) { 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; } *ccp = prev_ccline; diff --git a/src/file_search.c b/src/file_search.c index 0b688a2a10..0c06a4c091 100644 --- a/src/file_search.c +++ b/src/file_search.c @@ -44,6 +44,8 @@ * functions. */ +#include <string.h> + #include "vim.h" #include "file_search.h" #include "charset.h" @@ -278,7 +280,7 @@ vim_findfile_init ( search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T)); if (search_ctx == NULL) 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_tagfile = tagfile; diff --git a/src/fold.c b/src/fold.c index b38253d7a6..e48085791d 100644 --- a/src/fold.c +++ b/src/fold.c @@ -12,6 +12,8 @@ * fold.c: code for folding */ +#include <string.h> + #include "vim.h" #include "fold.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; if (level > (int)sizeof(dashes) - 1) level = (int)sizeof(dashes) - 1; - vim_memset(dashes, '-', (size_t)level); + memset(dashes, '-', (size_t)level); dashes[level] = NUL; set_vim_var_string(VV_FOLDDASHES, dashes, -1); set_vim_var_nr(VV_FOLDLEVEL, (long)level); diff --git a/src/garray.c b/src/garray.c index f991498a2b..023800429d 100644 --- a/src/garray.c +++ b/src/garray.c @@ -2,6 +2,8 @@ /// /// Functions for handling growing arrays. +#include <string.h> + #include "vim.h" #include "ascii.h" #include "misc2.h" @@ -77,7 +79,7 @@ int ga_grow(garray_T *gap, int n) return FAIL; } 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_data = pp; } diff --git a/src/getchar.c b/src/getchar.c index 87bd899880..e0b4b59e9d 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -16,6 +16,8 @@ * mappings and abbreviations */ +#include <string.h> + #include "vim.h" #include "getchar.h" #include "charset.h" @@ -3073,7 +3075,7 @@ static void map_free(mapblock_T **mpp) static void validate_maphash(void) { if (!maphash_valid) { - vim_memset(maphash, 0, sizeof(maphash)); + memset(maphash, 0, sizeof(maphash)); maphash_valid = TRUE; } } diff --git a/src/hardcopy.c b/src/hardcopy.c index a3e456678b..0b5d29e998 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -11,6 +11,8 @@ * hardcopy.c: printing to paper */ +#include <string.h> + #include "vim.h" #include "version_defs.h" #include "hardcopy.h" @@ -521,7 +523,7 @@ void ex_hardcopy(exarg_T *eap) int page_line; int jobsplit; - vim_memset(&settings, 0, sizeof(prt_settings_T)); + memset(&settings, 0, sizeof(prt_settings_T)); settings.has_color = TRUE; if (*eap->arg == '>') { @@ -625,7 +627,7 @@ void 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)); + memset(&page_prtpos, 0, sizeof(prt_pos_T)); page_prtpos.file_line = eap->line1; 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); 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 */ prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u), diff --git a/src/hashtab.c b/src/hashtab.c index ed198ecc6a..8e2a6dc337 100644 --- a/src/hashtab.c +++ b/src/hashtab.c @@ -18,6 +18,8 @@ /// of the entries is empty to keep the lookup efficient (at the cost of extra /// memory). +#include <string.h> + #include "vim.h" #include "hashtab.h" #include "message.h" @@ -35,7 +37,7 @@ static int hash_may_resize(hashtab_T *ht, int minitems); 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)); + memset(ht, 0, sizeof(hashtab_T)); ht->ht_array = ht->ht_smallarray; 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; } - 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 // the right spot. The new array won't have any removed items, thus this diff --git a/src/main.c b/src/main.c index 331801c46b..43045d7ae4 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,8 @@ */ #define EXTERN +#include <string.h> + #include "vim.h" #include "main.h" #include "blowfish.h" @@ -1493,7 +1495,7 @@ scripterror: * copied, so that they can be changed. */ 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->argv = argv; paramp->want_full_screen = TRUE; diff --git a/src/memfile.c b/src/memfile.c index 714a64fb6f..ffa92bfffe 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -32,6 +32,8 @@ * file is opened. */ +#include <string.h> + #include "vim.h" #include "memfile.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. * 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); return hp; @@ -1151,7 +1153,7 @@ mf_do_open ( */ 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_mask = MHT_INIT_SIZE - 1; } @@ -1284,7 +1286,7 @@ static int mf_hash_grow(mf_hashtab_T *mht) * 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) { j = (mhi->mhi_key >> shift) & (MHT_GROWTH_FACTOR - 1); diff --git a/src/memline.c b/src/memline.c index f0aca399b4..1130da901b 100644 --- a/src/memline.c +++ b/src/memline.c @@ -42,6 +42,8 @@ * mf_get(). */ +#include <string.h> + #include "vim.h" #include "memline.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. */ 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; } diff --git a/src/message.c b/src/message.c index 6a12517ba8..5d6606c15c 100644 --- a/src/message.c +++ b/src/message.c @@ -13,6 +13,8 @@ #define MESSAGE_FILE /* don't include prototype for smsg() */ +#include <string.h> + #include "vim.h" #include "message.h" #include "charset.h" @@ -3861,7 +3863,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; if (str_l < str_m) { 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); } @@ -3898,7 +3900,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; if (str_l < str_m) { 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); } @@ -3933,7 +3935,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; if (str_l < str_m) { size_t avail = str_m - str_l; - vim_memset(str + str_l, ' ', + memset(str + str_l, ' ', (size_t)pn > avail ? avail : (size_t)pn); } diff --git a/src/misc2.c b/src/misc2.c index 595d13cbec..eea138e10d 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -10,6 +10,8 @@ /* * misc2.c: Various functions. */ +#include <string.h> + #include "vim.h" #include "misc2.h" #include "file_search.h" @@ -716,7 +718,7 @@ char_u *alloc_clear(unsigned size) p = lalloc((long_u)size, TRUE); if (p != NULL) - (void)vim_memset(p, 0, (size_t)size); + (void)memset(p, 0, (size_t)size); return p; } @@ -745,7 +747,7 @@ char_u *lalloc_clear(long_u size, int message) p = (lalloc(size, message)); if (p != NULL) - (void)vim_memset(p, 0, (size_t)size); + (void)memset(p, 0, (size_t)size); 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 /* * Return zero when "b1" and "b2" are the same for "len" bytes. diff --git a/src/normal.c b/src/normal.c index 770a030db9..668319235d 100644 --- a/src/normal.c +++ b/src/normal.c @@ -12,6 +12,8 @@ * the operators. */ +#include <string.h> + #include "vim.h" #include "normal.h" #include "buffer.h" @@ -522,7 +524,7 @@ normal_cmd ( int idx; 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; /* 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; clear_oparg(&oa); - vim_memset(&ca, 0, sizeof(ca)); + memset(&ca, 0, sizeof(ca)); ca.oap = &oa; ca.cmdchar = c1; ca.nchar = c2; @@ -12,6 +12,8 @@ * op_change, op_yank, do_put, do_join */ +#include <string.h> + #include "vim.h" #include "ops.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)); if (newp == NULL) 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); copy_chars(newp + bd.textcol, (size_t)i, TAB); 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); if (newp == NULL) continue; - vim_memset(newp, NUL, (size_t)(oldlen + 1 + n)); + memset(newp, NUL, (size_t)(oldlen + 1 + n)); /* copy up to deleted part */ mch_memmove(newp, oldp, (size_t)bd.textcol); oldp += bd.textcol + bd.textlen; @@ -4985,7 +4987,7 @@ str_to_reg ( 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, diff --git a/src/quickfix.c b/src/quickfix.c index 1820f15af4..69052d14dd 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -11,6 +11,8 @@ * quickfix.c: functions for quickfix mode, using a file with error messages */ +#include <string.h> + #include "vim.h" #include "quickfix.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; } else 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) { 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)); 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++; } diff --git a/src/regexp.c b/src/regexp.c index 03ac02783e..4881267c69 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -44,6 +44,8 @@ /* #undef REGEXP_DEBUG */ /* #define REGEXP_DEBUG */ +#include <string.h> + #include "vim.h" #include "regexp.h" #include "charset.h" @@ -1334,7 +1336,7 @@ regcomp_start ( num_complex_braces = 0; regnpar = 1; - vim_memset(had_endbrace, 0, sizeof(had_endbrace)); + memset(had_endbrace, 0, sizeof(had_endbrace)); regnzpar = 1; re_has_z = 0; regsize = 0L; @@ -5515,11 +5517,11 @@ static void cleanup_subexpr(void) if (need_clear_subexpr) { if (REG_MULTI) { /* Use 0xff to set lnum to -1 */ - vim_memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); - vim_memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); + memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); + memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); } else { - vim_memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP); - vim_memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP); + memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP); + memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP); } need_clear_subexpr = FALSE; } @@ -5530,11 +5532,11 @@ static void cleanup_zsubexpr(void) if (need_clear_zsubexpr) { if (REG_MULTI) { /* Use 0xff to set lnum to -1 */ - vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP); - vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP); + memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP); + memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP); } else { - vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP); - vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP); + memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP); + memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP); } need_clear_zsubexpr = FALSE; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 7f4fb487f0..6e0e5d1f04 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -3544,10 +3544,10 @@ static void clear_sub(regsub_T *sub) { if (REG_MULTI) /* Use 0xff to set lnum to -1 */ - vim_memset(sub->list.multi, 0xff, + memset(sub->list.multi, 0xff, sizeof(struct multipos) * nfa_nsubexpr); 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; } diff --git a/src/screen.c b/src/screen.c index fa07cc651d..9d99ce0960 100644 --- a/src/screen.c +++ b/src/screen.c @@ -87,6 +87,8 @@ * update_screen() called to redraw. */ +#include <string.h> + #include "vim.h" #include "arabic.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); 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) ScreenAttrs[off + i] = attr; } @@ -6116,7 +6118,7 @@ retry: new_ScreenLines = (schar_T *)lalloc((long_u)( (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) { new_ScreenLinesUC = (u8char_T *)lalloc((long_u)( (Rows + 1) * Columns * sizeof(u8char_T)), FALSE); @@ -6197,20 +6199,20 @@ give_up: * executing an external command, for the GUI). */ if (!doclear) { - (void)vim_memset(new_ScreenLines + new_row * Columns, + (void)memset(new_ScreenLines + new_row * Columns, ' ', (size_t)Columns * sizeof(schar_T)); 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)); for (i = 0; i < p_mco; ++i) - (void)vim_memset(new_ScreenLinesC[i] + (void)memset(new_ScreenLinesC[i] + new_row * Columns, 0, (size_t)Columns * sizeof(u8char_T)); } 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)); - (void)vim_memset(new_ScreenAttrs + new_row * Columns, + (void)memset(new_ScreenAttrs + new_row * Columns, 0, (size_t)Columns * sizeof(sattr_T)); old_row = new_row + (screen_Rows - Rows); if (old_row >= 0 && ScreenLines != NULL) { @@ -6360,11 +6362,11 @@ static void screenclear2(void) */ 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) - (void)vim_memset(ScreenLinesUC + off, 0, + (void)memset(ScreenLinesUC + off, 0, (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) { - (void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T)); + (void)memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T)); } /* diff --git a/src/sha256.c b/src/sha256.c index 1670221929..0ccb13d763 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -13,6 +13,8 @@ /// 2. sha2_seed() generates a random header. /// sha256_self_test() is implicitly called once. +#include <string.h> + #include "vim.h" #include "sha256.h" @@ -342,7 +344,7 @@ int sha256_self_test(void) STRCPY(output, hexit); } else { sha256_start(&ctx); - vim_memset(buf, 'a', 1000); + memset(buf, 'a', 1000); for (j = 0; j < 1000; j++) { sha256_update(&ctx, (char_u *) buf, 1000); diff --git a/src/spell.c b/src/spell.c index 5bb6a70beb..4eae2b7991 100644 --- a/src/spell.c +++ b/src/spell.c @@ -297,6 +297,8 @@ * few bytes as possible, see offset2bytes()) */ +#include <string.h> + #include "vim.h" #include "spell.h" #include "buffer.h" @@ -1047,7 +1049,7 @@ spell_check ( if (wp->w_s->b_langp.ga_len == 0) 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 * 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. */ n = (int)(p - line) + 1; if (n < maxlen - 1) { - vim_memset(buf, ' ', n); + memset(buf, ' ', 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); if (ga_grow(gap, 256) == FAIL) return SP_OTHERERROR; - vim_memset(gap->ga_data, 0, sizeof(int *) * 256); + memset(gap->ga_data, 0, sizeof(int *) * 256); gap->ga_len = 256; /* 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 * 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; ) { c = mb_cptr2char_adv(&p); i = mb_cptr2char_adv(&s); @@ -4108,7 +4110,7 @@ theend: */ 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); wp->w_s->b_spell_ismw_mb = NULL; } @@ -6913,7 +6915,7 @@ static wordnode_T *get_wordnode(spellinfo_T *spin) else { n = spin->si_first_free; spin->si_first_free = n->wn_child; - vim_memset(n, 0, sizeof(wordnode_T)); + memset(n, 0, sizeof(wordnode_T)); --spin->si_free_count; } #ifdef SPELL_PRINTTREE @@ -8167,7 +8169,7 @@ mkspell ( int error = FALSE; spellinfo_T spin; - vim_memset(&spin, 0, sizeof(spin)); + memset(&spin, 0, sizeof(spin)); spin.si_verbose = !added_word; spin.si_ascii = ascii; spin.si_followup = TRUE; @@ -8641,8 +8643,8 @@ static void clear_spell_chartab(spelltab_T *sp) int i; /* Init everything to FALSE. */ - vim_memset(sp->st_isw, FALSE, sizeof(sp->st_isw)); - vim_memset(sp->st_isu, FALSE, sizeof(sp->st_isu)); + memset(sp->st_isw, FALSE, sizeof(sp->st_isw)); + memset(sp->st_isu, FALSE, sizeof(sp->st_isu)); for (i = 0; i < 256; ++i) { sp->st_fold[i] = i; sp->st_upper[i] = i; @@ -9471,7 +9473,7 @@ spell_find_suggest ( /* * 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_sga, (int)sizeof(suggest_T), 10); 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; sp = &stack[0]; - vim_memset(sp, 0, sizeof(trystate_T)); + memset(sp, 0, sizeof(trystate_T)); sp->ts_curi = 1; if (soundfold) { diff --git a/src/syntax.c b/src/syntax.c index fc326a8a6f..ca7bddb875 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -11,6 +11,8 @@ * syntax.c: code for syntax highlighting */ +#include <string.h> + #include "vim.h" #include "syntax.h" #include "charset.h" @@ -2583,7 +2585,7 @@ static int push_current_state(int idx) { if (ga_grow(¤t_state, 1) == 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; ++current_state.ga_len; return OK; @@ -4375,7 +4377,7 @@ syn_cmd_match ( /* get the pattern. */ init_syn_patterns(); - vim_memset(&item, 0, sizeof(item)); + memset(&item, 0, sizeof(item)); rest = get_syn_pattern(rest, &item); if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) syn_opt_arg.flags |= HL_HAS_EOL; @@ -4898,7 +4900,7 @@ static int syn_add_cluster(char_u *name) 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_u = vim_strsave_up(name); 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; 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; if (table == &term_attr_table) { 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) new_en = *char_aep; else { - vim_memset(&new_en, 0, sizeof(new_en)); + memset(&new_en, 0, sizeof(new_en)); if (char_attr <= HL_ALL) new_en.ae_attr = char_attr; } @@ -7073,7 +7075,7 @@ int hl_combine_attr(int char_attr, int prim_attr) if (char_aep != NULL) new_en = *char_aep; else { - vim_memset(&new_en, 0, sizeof(new_en)); + memset(&new_en, 0, sizeof(new_en)); if (char_attr <= HL_ALL) new_en.ae_attr = char_attr; } @@ -7535,7 +7537,7 @@ static int syn_add_group(char_u *name) 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_u = vim_strsave_up(name); ++highlight_ga.ga_len; @@ -7717,7 +7719,7 @@ int highlight_changed(void) return FAIL; hlcnt = highlight_ga.ga_len; 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]; id_S = hlcnt + 10; } @@ -7732,7 +7734,7 @@ int highlight_changed(void) highlight_user[i] = syn_id2attr(id); 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_cterm = highlight_attr[HLF_SNC]; hlt[hlcnt + i].sg_gui = highlight_attr[HLF_SNC]; @@ -11,6 +11,8 @@ * Code to handle tags and the tag stack */ +#include <string.h> + #include "vim.h" #include "tag.h" #include "buffer.h" @@ -1239,7 +1241,7 @@ find_tags ( /* This is only to avoid a compiler warning for using search_info * 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 @@ -2087,7 +2089,7 @@ get_tagfname ( char_u *r_ptr; if (first) - vim_memset(tnp, 0, sizeof(tagname_T)); + memset(tnp, 0, sizeof(tagname_T)); if (curbuf->b_help) { /* diff --git a/src/undo.c b/src/undo.c index 6a2d163f61..097b224d13 100644 --- a/src/undo.c +++ b/src/undo.c @@ -81,6 +81,8 @@ #define UH_MAGIC 0x18dade /* value for uh_magic when in use */ #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ +#include <string.h> + #include "vim.h" #include "undo.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)); if (uep == NULL) goto nomem; - vim_memset(uep, 0, sizeof(u_entry_T)); + memset(uep, 0, sizeof(u_entry_T)); #ifdef U_DEBUG uep->ue_magic = UE_MAGIC; #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)); if (uhp == NULL) return NULL; - vim_memset(uhp, 0, sizeof(u_header_T)); + memset(uhp, 0, sizeof(u_header_T)); #ifdef U_DEBUG uhp->uh_magic = UH_MAGIC; #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)); if (uep == NULL) return NULL; - vim_memset(uep, 0, sizeof(u_entry_T)); + memset(uep, 0, sizeof(u_entry_T)); #ifdef U_DEBUG uep->ue_magic = UE_MAGIC; #endif @@ -1031,7 +1033,7 @@ static u_entry_T *unserialize_uep(FILE *fp, int *error, char_u *file_name) *error = TRUE; return uep; } - vim_memset(array, 0, sizeof(char_u *) * uep->ue_size); + memset(array, 0, sizeof(char_u *) * uep->ue_size); } else array = NULL; uep->ue_array = array; @@ -1163,12 +1163,6 @@ void mch_memmove(void *, void *, size_t); #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 - #ifdef HAVE_MEMCMP # define vim_memcmp(p1, p2, len) memcmp((p1), (p2), (len)) #else |