aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c12
-rw-r--r--src/nvim/api/private/helpers.c8
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/buffer.c76
-rw-r--r--src/nvim/diff.c40
-rw-r--r--src/nvim/digraph.c16
-rw-r--r--src/nvim/edit.c66
-rw-r--r--src/nvim/eval.c306
-rw-r--r--src/nvim/ex_cmds.c132
-rw-r--r--src/nvim/ex_cmds2.c76
-rw-r--r--src/nvim/ex_docmd.c128
-rw-r--r--src/nvim/ex_eval.c22
-rw-r--r--src/nvim/ex_getln.c104
-rw-r--r--src/nvim/file_search.c50
-rw-r--r--src/nvim/fileio.c134
-rw-r--r--src/nvim/fold.c4
-rw-r--r--src/nvim/garray.c4
-rw-r--r--src/nvim/garray.h2
-rw-r--r--src/nvim/getchar.c56
-rw-r--r--src/nvim/hardcopy.c12
-rw-r--r--src/nvim/hashtab.c6
-rw-r--r--src/nvim/if_cscope.c98
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c4
-rw-r--r--src/nvim/lib/khash.h2
-rw-r--r--src/nvim/lib/klist.h6
-rw-r--r--src/nvim/lib/kvec.h2
-rw-r--r--src/nvim/main.c10
-rw-r--r--src/nvim/map.c2
-rw-r--r--src/nvim/mark.c40
-rw-r--r--src/nvim/mbyte.c18
-rw-r--r--src/nvim/memfile.c42
-rw-r--r--src/nvim/memline.c68
-rw-r--r--src/nvim/memory.c10
-rw-r--r--src/nvim/menu.c58
-rw-r--r--src/nvim/message.c36
-rw-r--r--src/nvim/misc1.c20
-rw-r--r--src/nvim/misc2.c8
-rw-r--r--src/nvim/msgpack_rpc/channel.c16
-rw-r--r--src/nvim/msgpack_rpc/remote_ui.c4
-rw-r--r--src/nvim/msgpack_rpc/server.c6
-rw-r--r--src/nvim/normal.c18
-rw-r--r--src/nvim/ops.c74
-rw-r--r--src/nvim/option.c46
-rw-r--r--src/nvim/os/env.c22
-rw-r--r--src/nvim/os/fs.c4
-rw-r--r--src/nvim/os/job_private.h9
-rw-r--r--src/nvim/os/pipe_process.c4
-rw-r--r--src/nvim/os/pty_process.c4
-rw-r--r--src/nvim/os/rstream.c10
-rw-r--r--src/nvim/os/shell.c10
-rw-r--r--src/nvim/os/wstream.c16
-rw-r--r--src/nvim/os_unix.c22
-rw-r--r--src/nvim/path.c52
-rw-r--r--src/nvim/popupmnu.c7
-rw-r--r--src/nvim/quickfix.c78
-rw-r--r--src/nvim/regexp.c30
-rw-r--r--src/nvim/regexp_nfa.c26
-rw-r--r--src/nvim/screen.c44
-rw-r--r--src/nvim/search.c50
-rw-r--r--src/nvim/spell.c164
-rw-r--r--src/nvim/strings.c2
-rw-r--r--src/nvim/syntax.c150
-rw-r--r--src/nvim/tag.c60
-rw-r--r--src/nvim/tempfile.c4
-rw-r--r--src/nvim/terminal.c12
-rw-r--r--src/nvim/tui/term_input.inl2
-rw-r--r--src/nvim/tui/tui.c10
-rw-r--r--src/nvim/undo.c40
-rw-r--r--src/nvim/window.c36
70 files changed, 1361 insertions, 1353 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 5bd48fc19f..c9ada8dfc0 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -58,7 +58,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
rv = slice.items[0].data.string;
}
- free(slice.items);
+ xfree(slice.items);
return rv;
}
@@ -144,10 +144,10 @@ ArrayOf(String) buffer_get_line_slice(Buffer buffer,
end:
if (err->set) {
for (size_t i = 0; i < rv.size; i++) {
- free(rv.items[i].data.string.data);
+ xfree(rv.items[i].data.string.data);
}
- free(rv.items);
+ xfree(rv.items);
rv.items = NULL;
}
@@ -280,7 +280,7 @@ void buffer_set_line_slice(Buffer buffer,
}
// Same as with replacing, but we also need to free lines
- free(lines[i]);
+ xfree(lines[i]);
lines[i] = NULL;
extra++;
}
@@ -301,10 +301,10 @@ void buffer_set_line_slice(Buffer buffer,
end:
for (size_t i = 0; i < new_len; i++) {
- free(lines[i]);
+ xfree(lines[i]);
}
- free(lines);
+ xfree(lines);
restore_win_for_buf(save_curwin, save_curtab, save_curbuf);
try_end(err);
}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 39ca0756f3..492da25a82 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -61,7 +61,7 @@ bool try_end(Error *err)
free_global_msglist();
if (should_free) {
- free(msg);
+ xfree(msg);
}
} else if (did_throw) {
api_set_error(err, Exception, "%s", current_exception->value);
@@ -489,7 +489,7 @@ void api_free_string(String value)
return;
}
- free(value.data);
+ xfree(value.data);
}
void api_free_object(Object value)
@@ -527,7 +527,7 @@ void api_free_array(Array value)
api_free_object(value.items[i]);
}
- free(value.items);
+ xfree(value.items);
}
void api_free_dictionary(Dictionary value)
@@ -537,7 +537,7 @@ void api_free_dictionary(Dictionary value)
api_free_object(value.items[i].value);
}
- free(value.items);
+ xfree(value.items);
}
Dictionary api_metadata(void)
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 587e19fe35..1204c9e1d1 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -85,7 +85,7 @@ void vim_feedkeys(String keys, String mode, Boolean escape_csi)
insert ? 0 : typebuf.tb_len, !typed, false);
if (escape_csi) {
- free(keys_esc);
+ xfree(keys_esc);
}
if (vgetc_busy)
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 11cb7bdeac..4585278714 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -443,8 +443,8 @@ close_buffer (
* Remove the buffer from the list.
*/
if (wipe_buf) {
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
if (buf->b_prev == NULL)
firstbuf = buf->b_next;
else
@@ -563,7 +563,7 @@ static void free_buffer(buf_T *buf)
buf->b_next = au_pending_free_buf;
au_pending_free_buf = buf;
} else {
- free(buf);
+ xfree(buf);
}
}
@@ -587,7 +587,7 @@ free_buffer_stuff (
buf_delete_signs(buf); /* delete any signs */
map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */
map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */
- free(buf->b_start_fenc);
+ xfree(buf->b_start_fenc);
buf->b_start_fenc = NULL;
}
@@ -605,7 +605,7 @@ static void clear_wininfo(buf_T *buf)
clear_winopt(&wip->wi_opt);
deleteFoldRecurse(&wip->wi_folds);
}
- free(wip);
+ xfree(wip);
}
}
@@ -1332,7 +1332,7 @@ buflist_new (
if (ffname != NULL && !(flags & BLN_DUMMY)
&& (buf = buflist_findname_file_id(ffname, &file_id,
file_id_valid)) != NULL) {
- free(ffname);
+ xfree(ffname);
if (lnum != 0)
buflist_setfpos(buf, curwin, lnum, (colnr_T)0, FALSE);
/* copy the options now, if 'cpo' doesn't have 's' and not done
@@ -1396,9 +1396,9 @@ buflist_new (
buf->b_wininfo = xcalloc(1, sizeof(wininfo_T));
if (ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) {
- free(buf->b_ffname);
+ xfree(buf->b_ffname);
buf->b_ffname = NULL;
- free(buf->b_sfname);
+ xfree(buf->b_sfname);
buf->b_sfname = NULL;
if (buf != curbuf)
free_buffer(buf);
@@ -1672,7 +1672,7 @@ buf_T *buflist_findname_exp(char_u *fname)
);
if (ffname != NULL) {
buf = buflist_findname(ffname);
- free(ffname);
+ xfree(ffname);
}
return buf;
}
@@ -1767,7 +1767,7 @@ buflist_findpat (
++p;
prog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
if (prog == NULL) {
- free(pat);
+ xfree(pat);
return -1;
}
@@ -1809,7 +1809,7 @@ buflist_findpat (
find_listed = FALSE;
}
- free(pat);
+ xfree(pat);
}
if (match == -2)
@@ -1855,7 +1855,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
prog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
if (prog == NULL) {
if (patc != pat)
- free(patc);
+ xfree(patc);
return FAIL;
}
@@ -1893,7 +1893,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
}
if (patc != pat)
- free(patc);
+ xfree(patc);
*num_file = count;
return count == 0 ? FAIL : OK;
@@ -1938,7 +1938,7 @@ static char_u *fname_match(regprog_T *prog, char_u *name, bool ignore_case)
p = home_replace_save(NULL, name);
if (vim_regexec(&regmatch, p, (colnr_T)0))
match = name;
- free(p);
+ xfree(p);
}
}
@@ -2223,8 +2223,8 @@ setfname (
if (ffname == NULL || *ffname == NUL) {
/* Removing the name. */
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
buf->b_ffname = NULL;
buf->b_sfname = NULL;
} else {
@@ -2245,7 +2245,7 @@ setfname (
if (obuf->b_ml.ml_mfp != NULL) { /* it's loaded, fail */
if (message)
EMSG(_("E95: Buffer with this name already exists"));
- free(ffname);
+ xfree(ffname);
return FAIL;
}
/* delete from the list */
@@ -2255,8 +2255,8 @@ setfname (
#ifdef USE_FNAME_CASE
path_fix_case(sfname); /* set correct case for short file name */
#endif
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
buf->b_ffname = ffname;
buf->b_sfname = sfname;
}
@@ -2282,8 +2282,8 @@ void buf_set_name(int fnum, char_u *name)
buf = buflist_findnr(fnum);
if (buf != NULL) {
- free(buf->b_sfname);
- free(buf->b_ffname);
+ xfree(buf->b_sfname);
+ xfree(buf->b_ffname);
buf->b_ffname = vim_strsave(name);
buf->b_sfname = NULL;
/* Allocate ffname and expand into full path. Also resolves .lnk
@@ -2561,7 +2561,7 @@ fileinfo (
set_keep_msg(p, 0);
}
- free(buffer);
+ xfree(buffer);
}
void col_print(char_u *buf, size_t buflen, int col, int vcol)
@@ -2636,7 +2636,7 @@ void maketitle(void)
else {
p = transstr(path_tail(curbuf->b_fname));
STRLCPY(buf, p, SPACE_FOR_FNAME + 1);
- free(p);
+ xfree(p);
}
switch (bufIsChanged(curbuf)
@@ -2677,7 +2677,7 @@ void maketitle(void)
if (off < SPACE_FOR_DIR) {
p = transstr(buf + off);
STRLCPY(buf + off, p, SPACE_FOR_DIR - off + 1);
- free(p);
+ xfree(p);
} else {
STRLCPY(buf + off, "...", SPACE_FOR_ARGNR - off + 1);
}
@@ -2749,7 +2749,7 @@ static int ti_change(char_u *str, char_u **last)
{
if ((str == NULL) != (*last == NULL)
|| (str != NULL && *last != NULL && STRCMP(str, *last) != 0)) {
- free(*last);
+ xfree(*last);
if (str == NULL)
*last = NULL;
else
@@ -2771,8 +2771,8 @@ void resettitle(void)
# if defined(EXITFREE)
void free_titles(void)
{
- free(lasttitle);
- free(lasticon);
+ xfree(lasttitle);
+ xfree(lasticon);
}
# endif
@@ -3124,7 +3124,7 @@ build_stl_str_hl (
if (str != NULL && *str != 0) {
if (*skipdigits(str) == NUL) {
num = atoi((char *)str);
- free(str);
+ xfree(str);
str = NULL;
itemisflag = FALSE;
}
@@ -3381,7 +3381,7 @@ build_stl_str_hl (
item[curitem].type = Empty;
if (opt == STL_VIM_EXPR)
- free(str);
+ xfree(str);
if (num >= 0 || (!itemisflag && str && *str))
prevchar_isflag = FALSE; /* Item not NULL, but not a flag */
@@ -3391,7 +3391,7 @@ build_stl_str_hl (
itemcnt = curitem;
if (usefmt != fmt)
- free(usefmt);
+ xfree(usefmt);
width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth) {
@@ -3585,7 +3585,7 @@ void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname)
/* If the file name is a shortcut file, use the file it links to. */
rfname = mch_resolve_shortcut(*ffname);
if (rfname != NULL) {
- free(*ffname);
+ xfree(*ffname);
*ffname = rfname;
*sfname = rfname;
}
@@ -3844,7 +3844,7 @@ do_arg_all (
win_enter(new_curwin, false);
--autocmd_no_leave;
- free(opened);
+ xfree(opened);
}
/*
@@ -4161,7 +4161,7 @@ chk_modeline (
sourcing_lnum = save_sourcing_lnum;
sourcing_name = save_sourcing_name;
- free(linecopy);
+ xfree(linecopy);
return retval;
}
@@ -4208,7 +4208,7 @@ int read_viminfo_bufferlist(vir_T *virp, int writing)
buflist_setfpos(buf, curwin, lnum, col, FALSE);
}
}
- free(xline);
+ xfree(xline);
return viminfo_readline(virp);
}
@@ -4249,7 +4249,7 @@ void write_viminfo_bufferlist(FILE *fp)
buf->b_last_cursor.col);
viminfo_writestring(fp, line);
}
- free(line);
+ xfree(line);
}
@@ -4426,7 +4426,7 @@ linenr_T buf_delsign(
if (sign->id == id) {
*lastp = next;
lnum = sign->lnum;
- free(sign);
+ xfree(sign);
break;
} else {
lastp = &sign->next;
@@ -4498,7 +4498,7 @@ void buf_delete_signs(buf_T *buf)
while (buf->b_signlist != NULL) {
next = buf->b_signlist->next;
- free(buf->b_signlist);
+ xfree(buf->b_signlist);
buf->b_signlist = next;
}
}
@@ -4621,7 +4621,7 @@ int buf_contents_changed(buf_T *buf)
}
}
}
- free(ea.cmd);
+ xfree(ea.cmd);
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index e50b096270..937baad648 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -393,7 +393,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
}
}
dprev->df_next = dp->df_next;
- free(dp);
+ xfree(dp);
dp = dprev->df_next;
} else {
// Advance to next entry.
@@ -416,7 +416,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
if (i == DB_COUNT) {
diff_T *dnext = dp->df_next;
- free(dp);
+ xfree(dp);
dp = dnext;
if (dprev == NULL) {
@@ -527,7 +527,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp)
break;
}
}
- free(line_org);
+ xfree(line_org);
// Stop when a line isn't equal in all diff buffers.
if (i_new != DB_COUNT) {
@@ -786,9 +786,9 @@ void ex_diffupdate(exarg_T *eap)
diff_redraw(TRUE);
theend:
- free(tmp_orig);
- free(tmp_new);
- free(tmp_diff);
+ xfree(tmp_orig);
+ xfree(tmp_new);
+ xfree(tmp_diff);
}
/// Make a diff between files "tmp_orig" and "tmp_new", results in "tmp_diff".
@@ -828,7 +828,7 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
NULL
);
unblock_autocmds();
- free(cmd);
+ xfree(cmd);
}
}
@@ -989,16 +989,16 @@ theend:
if (tmp_orig != NULL) {
os_remove((char *)tmp_orig);
}
- free(tmp_orig);
+ xfree(tmp_orig);
if (tmp_new != NULL) {
os_remove((char *)tmp_new);
}
- free(tmp_new);
- free(newname);
- free(buf);
+ xfree(tmp_new);
+ xfree(newname);
+ xfree(buf);
#ifdef UNIX
- free(fullname);
+ xfree(fullname);
#endif // ifdef UNIX
}
@@ -1340,7 +1340,7 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname)
while (dn != dp->df_next) {
dpl = dn->df_next;
- free(dn);
+ xfree(dn);
dn = dpl;
}
} else {
@@ -1407,7 +1407,7 @@ void diff_clear(tabpage_T *tp)
diff_T *next_p;
for (p = tp->tp_first_diff; p != NULL; p = next_p) {
next_p = p->df_next;
- free(p);
+ xfree(p);
}
tp->tp_first_diff = NULL;
}
@@ -1559,7 +1559,7 @@ static int diff_equal_entry(diff_T *dp, int idx1, int idx2)
int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2],
dp->df_lnum[idx2] + i, FALSE));
- free(line);
+ xfree(line);
if (cmp != 0) {
return FALSE;
@@ -1863,7 +1863,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
int idx = diff_buf_idx(wp->w_buffer);
if (idx == DB_COUNT) {
// cannot happen
- free(line_org);
+ xfree(line_org);
return FALSE;
}
@@ -1876,7 +1876,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
}
if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) {
- free(line_org);
+ xfree(line_org);
return FALSE;
}
@@ -1956,7 +1956,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
}
}
- free(line_org);
+ xfree(line_org);
return added;
}
@@ -2262,7 +2262,7 @@ void ex_diffgetput(exarg_T *eap)
}
p = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from], nr, FALSE));
ml_append(lnum + i - 1, p, 0, FALSE);
- free(p);
+ xfree(p);
added++;
if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) {
// Added the first line into an empty buffer, need to
@@ -2317,7 +2317,7 @@ void ex_diffgetput(exarg_T *eap)
if (dfree != NULL) {
// Diff is deleted, update folds in other windows.
diff_fold_update(dfree, idx_to);
- free(dfree);
+ xfree(dfree);
} else {
// mark_adjust() may have changed the count in a wrong way
dp->df_count[idx_to] = new_count;
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index cb6bfc9cc9..cf998c041d 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1538,7 +1538,7 @@ static int getexactdigraph(int char1, int char2, int meta_char)
if (to != NULL) {
retval = (*mb_ptr2char)(to);
- free(to);
+ xfree(to);
}
(void)convert_setup(&vc, NULL, NULL);
}
@@ -1763,11 +1763,11 @@ char_u* keymap_init(void)
curbuf->b_p_keymap);
if (source_runtime((char_u *)buf, FALSE) == FAIL) {
- free(buf);
+ xfree(buf);
return (char_u *)N_("E544: Keymap file not found");
}
}
- free(buf);
+ xfree(buf);
}
return NULL;
@@ -1824,12 +1824,12 @@ void ex_loadkeymap(exarg_T *eap)
if (*kp->to == NUL) {
EMSG(_("E791: Empty keymap entry"));
}
- free(kp->from);
- free(kp->to);
+ xfree(kp->from);
+ xfree(kp->to);
--curbuf->b_kmap_ga.ga_len;
}
}
- free(line);
+ xfree(line);
}
// setup ":lnoremap" to map the keys
@@ -1866,8 +1866,8 @@ static void keymap_unload(void)
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) {
vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from);
(void)do_map(1, buf, LANGMAP, FALSE);
- free(kp[i].from);
- free(kp[i].to);
+ xfree(kp[i].from);
+ xfree(kp[i].to);
}
p_cpo = save_cpo;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index b860ce8898..26665aa84c 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -482,7 +482,7 @@ edit (
new_insert_skip = 0;
else {
new_insert_skip = (int)STRLEN(ptr);
- free(ptr);
+ xfree(ptr);
}
old_indent = 0;
@@ -652,7 +652,7 @@ edit (
if (str != NULL) {
for (p = str; *p != NUL; mb_ptr_adv(p))
ins_compl_addleader(PTR2CHAR(p));
- free(str);
+ xfree(str);
} else
ins_compl_addleader(c);
continue;
@@ -1153,7 +1153,7 @@ normalchar:
}
AppendToRedobuffLit(str, -1);
}
- free(str);
+ xfree(str);
c = NUL;
}
@@ -1569,7 +1569,7 @@ change_indent (
memset(ptr, ' ', i);
new_cursor_col += i;
ins_str(ptr);
- free(ptr);
+ xfree(ptr);
}
/*
@@ -1648,7 +1648,7 @@ change_indent (
/* Insert new stuff into line again */
ins_bytes(new_line);
- free(new_line);
+ xfree(new_line);
}
}
@@ -1970,7 +1970,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
*(p++) = wca[i++];
*p = NUL;
- free(wca);
+ xfree(wca);
return ins_compl_add(IObuff, len, icase, fname, NULL, dir,
flags, FALSE);
@@ -2273,7 +2273,7 @@ static void ins_compl_del_pum(void)
{
if (compl_match_array != NULL) {
pum_undisplay();
- free(compl_match_array);
+ xfree(compl_match_array);
compl_match_array = NULL;
}
}
@@ -2490,8 +2490,8 @@ ins_compl_dictionaries (
ptr = xmalloc(len);
vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
- free(pat_esc);
- free(ptr);
+ xfree(pat_esc);
+ xfree(ptr);
} else {
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL)
@@ -2539,7 +2539,7 @@ ins_compl_dictionaries (
theend:
p_scs = save_p_scs;
vim_regfree(regmatch.regprog);
- free(buf);
+ xfree(buf);
}
static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir)
@@ -2689,9 +2689,9 @@ static void ins_compl_free(void)
compl_T *match;
int i;
- free(compl_pattern);
+ xfree(compl_pattern);
compl_pattern = NULL;
- free(compl_leader);
+ xfree(compl_leader);
compl_leader = NULL;
if (compl_first_match == NULL)
@@ -2704,13 +2704,13 @@ static void ins_compl_free(void)
do {
match = compl_curr_match;
compl_curr_match = compl_curr_match->cp_next;
- free(match->cp_str);
+ xfree(match->cp_str);
/* several entries may use the same fname, free it just once. */
if (match->cp_flags & FREE_FNAME)
- free(match->cp_fname);
+ xfree(match->cp_fname);
for (i = 0; i < CPT_COUNT; ++i)
- free(match->cp_text[i]);
- free(match);
+ xfree(match->cp_text[i]);
+ xfree(match);
} while (compl_curr_match != NULL && compl_curr_match != compl_first_match);
compl_first_match = compl_curr_match = NULL;
compl_shown_match = NULL;
@@ -2721,12 +2721,12 @@ static void ins_compl_clear(void)
compl_cont_status = 0;
compl_started = FALSE;
compl_matches = 0;
- free(compl_pattern);
+ xfree(compl_pattern);
compl_pattern = NULL;
- free(compl_leader);
+ xfree(compl_leader);
compl_leader = NULL;
edit_submode_extra = NULL;
- free(compl_orig_text);
+ xfree(compl_orig_text);
compl_orig_text = NULL;
compl_enter_selects = FALSE;
}
@@ -2767,7 +2767,7 @@ static int ins_compl_bs(void)
|| ins_compl_need_restart())
ins_compl_restart();
- free(compl_leader);
+ xfree(compl_leader);
compl_leader = vim_strnsave(line + compl_col, (int)(p - line) - compl_col);
ins_compl_new_leader();
if (compl_shown_match != NULL)
@@ -2871,7 +2871,7 @@ static void ins_compl_addleader(int c)
* cursor doesn't point original position, changing compl_leader would
* break redo. */
if (!compl_opt_refresh_always) {
- free(compl_leader);
+ xfree(compl_leader);
compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
(int)(curwin->w_cursor.col - compl_col));
ins_compl_new_leader();
@@ -2898,7 +2898,7 @@ static void ins_compl_set_original_text(char_u *str)
{
/* Replace the original text entry. */
if (compl_first_match->cp_flags & ORIGINAL_TEXT) { /* safety check */
- free(compl_first_match->cp_str);
+ xfree(compl_first_match->cp_str);
compl_first_match->cp_str = vim_strsave(str);
}
}
@@ -4449,13 +4449,13 @@ static int ins_complete(int c)
ins_compl_fixRedoBufForLeader(NULL);
/* Always add completion for the original text. */
- free(compl_orig_text);
+ xfree(compl_orig_text);
compl_orig_text = vim_strnsave(line + compl_col, compl_length);
if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0,
ORIGINAL_TEXT, FALSE) != OK) {
- free(compl_pattern);
+ xfree(compl_pattern);
compl_pattern = NULL;
- free(compl_orig_text);
+ xfree(compl_orig_text);
compl_orig_text = NULL;
return FAIL;
}
@@ -5326,7 +5326,7 @@ internal_format (
* moved, now we re-insert it into the new line.
*/
ins_bytes(saved_text);
- free(saved_text);
+ xfree(saved_text);
} else {
/*
* Check if cursor is not past the NUL off the line, cindent
@@ -5661,11 +5661,11 @@ stop_insert (
ptr = get_inserted();
if (did_restart_edit == 0 || (ptr != NULL
&& (int)STRLEN(ptr) > new_insert_skip)) {
- free(last_insert);
+ xfree(last_insert);
last_insert = ptr;
last_insert_skip = new_insert_skip;
} else
- free(ptr);
+ xfree(ptr);
if (!arrow_used && end_insert_pos != NULL) {
/* Auto-format now. It may seem strange to do this when stopping an
@@ -5770,7 +5770,7 @@ void set_last_insert(int c)
{
char_u *s;
- free(last_insert);
+ xfree(last_insert);
last_insert = xmalloc(MB_MAXBYTES * 3 + 5);
s = last_insert;
/* Use the CTRL-V only when entering a special char */
@@ -5785,9 +5785,9 @@ void set_last_insert(int c)
#if defined(EXITFREE)
void free_last_insert(void)
{
- free(last_insert);
+ xfree(last_insert);
last_insert = NULL;
- free(compl_orig_text);
+ xfree(compl_orig_text);
compl_orig_text = NULL;
}
@@ -6307,7 +6307,7 @@ static void mb_replace_pop_ins(int cc)
*/
static void replace_flush(void)
{
- free(replace_stack);
+ xfree(replace_stack);
replace_stack = NULL;
replace_stack_len = 0;
replace_stack_nr = 0;
@@ -7966,7 +7966,7 @@ static int ins_tab(void)
}
if (State & VREPLACE_FLAG)
- free(saved_line);
+ xfree(saved_line);
curwin->w_p_list = save_list;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 67cef68b38..1616bf60e2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -513,7 +513,7 @@ void eval_clear(void)
for (int i = 0; i < VV_LEN; ++i) {
p = &vimvars[i];
if (p->vv_di.di_tv.v_type == VAR_STRING) {
- free(p->vv_str);
+ xfree(p->vv_str);
p->vv_str = NULL;
} else if (p->vv_di.di_tv.v_type == VAR_LIST) {
list_unref(p->vv_list);
@@ -539,7 +539,7 @@ void eval_clear(void)
for (int i = 1; i <= ga_scripts.ga_len; ++i)
vars_clear(&SCRIPT_VARS(i));
for (int i = 1; i <= ga_scripts.ga_len; ++i)
- free(SCRIPT_SV(i));
+ xfree(SCRIPT_SV(i));
ga_clear(&ga_scripts);
/* unreferenced lists and dicts */
@@ -735,13 +735,13 @@ void var_redir_stop(void)
}
/* free the collected output */
- free(redir_ga.ga_data);
+ xfree(redir_ga.ga_data);
redir_ga.ga_data = NULL;
- free(redir_lval);
+ xfree(redir_lval);
redir_lval = NULL;
}
- free(redir_varname);
+ xfree(redir_varname);
redir_varname = NULL;
}
@@ -1059,7 +1059,7 @@ typval_T *eval_expr(char_u *arg, char_u **nextcmd)
typval_T *tv = xmalloc(sizeof(typval_T));
if (eval0(arg, tv, nextcmd, TRUE) == FAIL) {
- free(tv);
+ xfree(tv);
return NULL;
}
@@ -1126,7 +1126,7 @@ call_vim_function (
--sandbox;
restore_funccal(save_funccalp);
}
- free(argvars);
+ xfree(argvars);
if (ret == FAIL)
clear_tv(rettv);
@@ -1691,14 +1691,14 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first)
s == NULL ? (char_u *)"" : s,
first);
*arg = c;
- free(tf);
+ xfree(tf);
}
clear_tv(&tv);
}
}
}
- free(tofree);
+ xfree(tofree);
}
arg = skipwhite(arg);
@@ -1756,7 +1756,7 @@ ex_let_one (
if (s != NULL) {
p = tofree = concat_str(s, p);
if (mustfree)
- free(s);
+ xfree(s);
}
}
if (p != NULL) {
@@ -1771,7 +1771,7 @@ ex_let_one (
arg_end = arg;
}
name[len] = c1;
- free(tofree);
+ xfree(tofree);
}
}
}
@@ -1812,7 +1812,7 @@ ex_let_one (
n = numval - n;
} else if (opt_type == 0 && stringval != NULL) { /* string */
s = concat_str(stringval, s);
- free(stringval);
+ xfree(stringval);
stringval = s;
}
}
@@ -1822,7 +1822,7 @@ ex_let_one (
arg_end = p;
}
*p = c1;
- free(stringval);
+ xfree(stringval);
}
}
/*
@@ -1844,14 +1844,14 @@ ex_let_one (
s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc);
if (s != NULL) {
p = ptofree = concat_str(s, p);
- free(s);
+ xfree(s);
}
}
if (p != NULL) {
write_reg_contents(*arg == '@' ? '"' : *arg, p, -1, FALSE);
arg_end = arg + 1;
}
- free(ptofree);
+ xfree(ptofree);
}
}
/*
@@ -2211,8 +2211,8 @@ get_lval (
*/
static void clear_lval(lval_T *lp)
{
- free(lp->ll_exp_name);
- free(lp->ll_newkey);
+ xfree(lp->ll_exp_name);
+ xfree(lp->ll_newkey);
}
/*
@@ -2305,7 +2305,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch
/* Need to add an item to the Dictionary. */
di = dictitem_alloc(lp->ll_newkey);
if (dict_add(lp->ll_tv->vval.v_dict, di) == FAIL) {
- free(di);
+ xfree(di);
return;
}
lp->ll_tv = &di->di_tv;
@@ -2540,7 +2540,7 @@ void free_for_info(void *fi_void)
list_rem_watch(fi->fi_list, &fi->fi_lw);
list_unref(fi->fi_list);
}
- free(fi);
+ xfree(fi);
}
@@ -2654,7 +2654,7 @@ void ex_call(exarg_T *eap)
if (fudi.fd_newkey != NULL) {
/* Still need to give an error message for missing key. */
EMSG2(_(e_dictkey), fudi.fd_newkey);
- free(fudi.fd_newkey);
+ xfree(fudi.fd_newkey);
}
if (tofree == NULL)
return;
@@ -2734,7 +2734,7 @@ void ex_call(exarg_T *eap)
end:
dict_unref(fudi.fd_dict);
- free(tofree);
+ xfree(tofree);
}
/*
@@ -3055,7 +3055,7 @@ static char_u *cat_prefix_varname(int prefix, char_u *name)
size_t len = STRLEN(name) + 3;
if (len > varnamebuflen) {
- free(varnamebuf);
+ xfree(varnamebuf);
len += 10; /* some additional space */
varnamebuf = xmalloc(len);
varnamebuflen = len;
@@ -3142,7 +3142,7 @@ char_u *get_user_var_name(expand_T *xp, int idx)
if (vidx < VV_LEN)
return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name);
- free(varnamebuf);
+ xfree(varnamebuf);
varnamebuf = NULL;
varnamebuflen = 0;
return NULL;
@@ -4150,7 +4150,7 @@ eval7 (
else
ret = OK;
}
- free(alias);
+ xfree(alias);
}
*arg = skipwhite(*arg);
@@ -4784,9 +4784,9 @@ list_free (
if (recurse || (item->li_tv.v_type != VAR_LIST
&& item->li_tv.v_type != VAR_DICT))
clear_tv(&item->li_tv);
- free(item);
+ xfree(item);
}
- free(l);
+ xfree(l);
}
/*
@@ -4803,7 +4803,7 @@ listitem_T *listitem_alloc(void) FUNC_ATTR_NONNULL_RET
void listitem_free(listitem_T *item)
{
clear_tv(&item->li_tv);
- free(item);
+ xfree(item);
}
/*
@@ -5275,7 +5275,7 @@ static list_T *list_copy(list_T *orig, int deep, int copyID)
ni = listitem_alloc();
if (deep) {
if (item_copy(&item->li_tv, &ni->li_tv, deep, copyID) == FAIL) {
- free(ni);
+ xfree(ni);
break;
}
} else
@@ -5330,7 +5330,7 @@ static char_u *list2string(typval_T *tv, int copyID)
ga_init(&ga, (int)sizeof(char), 80);
ga_append(&ga, '[');
if (list_join(&ga, tv->vval.v_list, (char_u *)", ", FALSE, copyID) == FAIL) {
- free(ga.ga_data);
+ xfree(ga.ga_data);
return NULL;
}
ga_append(&ga, ']');
@@ -5423,7 +5423,7 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int
ga_init(&join_ga, (int)sizeof(join_T), l->lv_len);
retval = list_join_inner(gap, l, sep, echo_style, copyID, &join_ga);
-# define FREE_JOIN_TOFREE(join) free((join)->tofree)
+# define FREE_JOIN_TOFREE(join) xfree((join)->tofree)
GA_DEEP_CLEAR(&join_ga, join_T, FREE_JOIN_TOFREE);
return retval;
@@ -5729,12 +5729,12 @@ dict_free (
if (recurse || (di->di_tv.v_type != VAR_LIST
&& di->di_tv.v_type != VAR_DICT))
clear_tv(&di->di_tv);
- free(di);
+ xfree(di);
--todo;
}
}
hash_clear(&d->dv_hashtab);
- free(d);
+ xfree(d);
}
/*
@@ -5787,7 +5787,7 @@ static void dictitem_remove(dict_T *dict, dictitem_T *item)
void dictitem_free(dictitem_T *item)
{
clear_tv(&item->di_tv);
- free(item);
+ xfree(item);
}
/*
@@ -5820,7 +5820,7 @@ static dict_T *dict_copy(dict_T *orig, int deep, int copyID)
if (deep) {
if (item_copy(&HI2DI(hi)->di_tv, &di->di_tv, deep,
copyID) == FAIL) {
- free(di);
+ xfree(di);
break;
}
} else
@@ -5929,7 +5929,7 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len)
}
hi = hash_find(&d->dv_hashtab, akey);
- free(tofree);
+ xfree(tofree);
if (HASHITEM_EMPTY(hi))
return NULL;
return HI2DI(hi);
@@ -5960,7 +5960,7 @@ static bool get_dict_callback(dict_T *d, char *key, ufunc_T **result)
if (*n > '9' || *n < '0') {
if ((n = trans_function_name(&n, false, TFN_INT|TFN_QUIET, NULL))) {
rv = find_func(n);
- free(n);
+ xfree(n);
}
} else {
// dict function, name is already translated
@@ -6045,20 +6045,20 @@ static char_u *dict2string(typval_T *tv, int copyID)
tofree = string_quote(hi->hi_key, FALSE);
if (tofree != NULL) {
ga_concat(&ga, tofree);
- free(tofree);
+ xfree(tofree);
}
ga_concat(&ga, (char_u *)": ");
s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID);
if (s != NULL)
ga_concat(&ga, s);
- free(tofree);
+ xfree(tofree);
if (s == NULL || did_echo_string_emsg) {
break;
}
line_breakcheck();
}
if (todo > 0) {
- free(ga.ga_data);
+ xfree(ga.ga_data);
return NULL;
}
@@ -6374,13 +6374,13 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
}
} else {
if (mustfree) {
- free(string);
+ xfree(string);
}
// Next try expanding things like $VIM and ${HOME}.
string = expand_env_save(name - 1);
if (string != NULL && *string == '$') {
- free(string);
+ xfree(string);
string = NULL;
}
}
@@ -7030,8 +7030,8 @@ call_func (
}
if (fname != name && fname != fname_buf)
- free(fname);
- free(name);
+ xfree(fname);
+ xfree(name);
return ret;
}
@@ -7050,7 +7050,7 @@ static void emsg_funcname(char *ermsg, char_u *name)
p = name;
EMSG2(_(ermsg), p);
if (p != name)
- free(p);
+ xfree(p);
}
/*
@@ -8200,7 +8200,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv)
p = expand_env_save(p);
if (p != NULL && *p != '$')
n = TRUE;
- free(p);
+ xfree(p);
}
} else if (*p == '&' || *p == '+') { /* option */
n = (get_option_tv(&p, NULL, TRUE) == OK);
@@ -8236,7 +8236,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv)
if (*p != NUL)
n = FALSE;
- free(tofree);
+ xfree(tofree);
}
rettv->vval.v_number = n;
@@ -8529,7 +8529,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what)
if (*fname != NUL && !error) {
do {
if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)
- free(fresult);
+ xfree(fresult);
fresult = find_file_in_path_option(first ? fname : NULL,
first ? (int)STRLEN(fname) : 0,
0, first, path,
@@ -8792,7 +8792,7 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv)
rettv->vval.v_string = NULL;
else
rettv->vval.v_string = vim_strnsave(fname, len);
- free(fbuf);
+ xfree(fbuf);
}
@@ -9275,7 +9275,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
slash_adjust(rettv->vval.v_string);
#endif
}
- free(cwd);
+ xfree(cwd);
}
/*
@@ -10252,8 +10252,8 @@ static void f_iconv(typval_T *argvars, typval_T *rettv)
rettv->vval.v_string = string_convert(&vimconv, str, NULL);
convert_setup(&vimconv, NULL, NULL);
- free(from);
- free(to);
+ xfree(from);
+ xfree(to);
}
/*
@@ -10391,7 +10391,7 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog)
rettv->vval.v_string = vim_strsave(get_tv_string_buf(
&argvars[2], buf));
- free(xp_arg);
+ xfree(xp_arg);
/* since the user typed this, no need to wait for return */
need_wait_return = FALSE;
@@ -10742,7 +10742,7 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv)
return;
}
- WBuffer *buf = wstream_new_buffer(input, input_len, 1, free);
+ WBuffer *buf = wstream_new_buffer(input, input_len, 1, xfree);
rettv->vval.v_number = job_write(job, buf);
}
@@ -11239,7 +11239,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
keys = replace_termcodes(keys, &keys_buf, TRUE, TRUE, FALSE);
rhs = check_map(keys, mode, exact, FALSE, abbr, &mp, &buffer_local);
- free(keys_buf);
+ xfree(keys_buf);
if (!get_dict) {
/* Return a string. */
@@ -11264,8 +11264,8 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
dict_add_nr_str(dict, "nowait", mp->m_nowait ? 1L : 0L, NULL);
dict_add_nr_str(dict, "mode", 0L, mapmode);
- free(lhs);
- free(mapmode);
+ xfree(lhs);
+ xfree(mapmode);
}
}
}
@@ -11412,7 +11412,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type)
match = FALSE;
break;
}
- free(tofree);
+ xfree(tofree);
str = echo_string(&li->li_tv, &tofree, strbuf, 0);
if (str == NULL)
break;
@@ -11476,7 +11476,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type)
}
theend:
- free(tofree);
+ xfree(tofree);
p_cpo = save_cpo;
}
@@ -11710,7 +11710,7 @@ static int mkdir_recurse(char_u *dir, int prot)
r = OK;
else if (mkdir_recurse(updir, prot) == OK)
r = vim_mkdir_emsg(updir, prot);
- free(updir);
+ xfree(updir);
return r;
}
@@ -12139,7 +12139,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
--cnt;
}
- free(prev);
+ xfree(prev);
fclose(fd);
}
@@ -12289,7 +12289,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv)
// Remove one item, return its value.
vim_list_remove(l, item, item);
*rettv = item->li_tv;
- free(item);
+ xfree(item);
} else {
/* Remove range of items, return list with values. */
end = get_tv_number_chk(&argvars[2], &error);
@@ -12432,8 +12432,8 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
buf[len] = NUL;
if (limit-- == 0) {
- free(p);
- free(remain);
+ xfree(p);
+ xfree(remain);
EMSG(_("E655: Too many symbolic links (cycle?)"));
rettv->vval.v_string = NULL;
goto fail;
@@ -12451,7 +12451,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
cpy = remain;
remain = remain ?
concat_str(q - 1, remain) : (char_u *) xstrdup((char *)q - 1);
- free(cpy);
+ xfree(cpy);
q[-1] = NUL;
}
@@ -12466,10 +12466,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
cpy = xmalloc(STRLEN(p) + STRLEN(buf) + 1);
STRCPY(cpy, p);
STRCPY(path_tail(cpy), buf);
- free(p);
+ xfree(p);
p = cpy;
} else {
- free(p);
+ xfree(p);
p = vim_strsave(buf);
}
}
@@ -12482,14 +12482,14 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
len = q - remain - (*q != NUL);
cpy = vim_strnsave(p, STRLEN(p) + len);
STRNCAT(cpy, remain, len);
- free(p);
+ xfree(p);
p = cpy;
/* Shorten "remain". */
if (*q != NUL)
STRMOVE(remain, q - 1);
else {
- free(remain);
+ xfree(remain);
remain = NULL;
}
}
@@ -12507,7 +12507,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|| vim_ispathsep(p[2])))))) {
/* Prepend "./". */
cpy = concat_str((char_u *)"./", p);
- free(p);
+ xfree(p);
p = cpy;
} else if (!is_relative_to_current) {
/* Strip leading "./". */
@@ -12538,7 +12538,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
#ifdef HAVE_READLINK
fail:
- free(buf);
+ xfree(buf);
#endif
rettv->v_type = VAR_STRING;
}
@@ -13256,8 +13256,8 @@ do_searchpair (
if ((flags & SP_NOMOVE) || retval == 0)
curwin->w_cursor = save_cursor;
- free(pat2);
- free(pat3);
+ xfree(pat2);
+ xfree(pat3);
if (p_cpo == empty_option)
p_cpo = save_cpo;
else
@@ -13329,7 +13329,7 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv)
STRCPY(bufvarname, "b:");
STRCPY(bufvarname + 2, varname);
set_var(bufvarname, varp, TRUE);
- free(bufvarname);
+ xfree(bufvarname);
}
/* reset notion of buffer */
@@ -13632,8 +13632,8 @@ static void f_setreg(typval_T *argvars, typval_T *rettv)
free_lstval:
while (curallocval > allocval)
- free(*--curallocval);
- free(lstval);
+ xfree(*--curallocval);
+ xfree(lstval);
} else {
char_u *strval = get_tv_string_chk(&argvars[1]);
if (strval == NULL) {
@@ -13673,7 +13673,7 @@ static void f_settabvar(typval_T *argvars, typval_T *rettv)
STRCPY(tabvarname, "t:");
STRCPY(tabvarname + 2, varname);
set_var(tabvarname, varp, TRUE);
- free(tabvarname);
+ xfree(tabvarname);
/* Restore current tabpage */
if (valid_tabpage(save_curtab))
@@ -13739,7 +13739,7 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off)
STRCPY(winvarname, "w:");
STRCPY(winvarname + 2, varname);
set_var(winvarname, varp, TRUE);
- free(winvarname);
+ xfree(winvarname);
}
restore_win(save_curwin, save_curtab, TRUE);
}
@@ -13888,8 +13888,8 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
res = si1->idx > si2->idx ? 1 : -1;
}
- free(tofree1);
- free(tofree2);
+ xfree(tofree1);
+ xfree(tofree2);
return res;
}
@@ -14095,7 +14095,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
}
}
- free(ptrs);
+ xfree(ptrs);
}
}
@@ -14365,7 +14365,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv)
result_buf[0] = NUL;
if (conv.vc_type != CONV_NONE)
- free(p);
+ xfree(p);
convert_setup(&conv, enc, p_enc);
if (conv.vc_type != CONV_NONE)
rettv->vval.v_string = string_convert(&conv, result_buf, NULL);
@@ -14374,7 +14374,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv)
/* Release conversion descriptors */
convert_setup(&conv, NULL, NULL);
- free(enc);
+ xfree(enc);
}
}
@@ -14862,7 +14862,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
char *res = NULL;
int status = os_system(cmd, input, input_len, &res, &nread);
- free(input);
+ xfree(input);
set_vim_var_nr(VV_SHELL_ERROR, (long) status);
@@ -14885,7 +14885,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
rettv->vval.v_list->lv_refcount++;
rettv->v_type = VAR_LIST;
- free(res);
+ xfree(res);
} else {
// res may contain several NULs before the final terminating one.
// Replace them with SOH (1) like in get_cmd_output() to avoid truncation.
@@ -15043,7 +15043,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv)
}
tagname_free(&tn);
- free(fname);
+ xfree(fname);
}
/*
@@ -15372,7 +15372,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv)
if (ffname != NULL)
rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE);
- free(ffname);
+ xfree(ffname);
}
}
}
@@ -16115,7 +16115,7 @@ static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *
STRCAT(retval, temp_result);
STRCAT(retval, expr_end + 1);
}
- free(temp_result);
+ xfree(temp_result);
*in_end = c1; /* put char back for error messages */
*expr_start = '{';
@@ -16127,7 +16127,7 @@ static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *
/* Further expansion! */
temp_result = make_expanded_name(retval, expr_start,
expr_end, temp_result);
- free(retval);
+ xfree(retval);
retval = temp_result;
}
}
@@ -16228,7 +16228,7 @@ set_vim_var_string (
* Will always be invoked when "v:progname" is set. */
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
- free(vimvars[idx].vv_str);
+ xfree(vimvars[idx].vv_str);
if (val == NULL)
vimvars[idx].vv_str = NULL;
else if (len == -1)
@@ -16307,7 +16307,7 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
oldval = vimvars[VV_CMDARG].vv_str;
if (eap == NULL) {
- free(oldval);
+ xfree(oldval);
vimvars[VV_CMDARG].vv_str = oldarg;
return NULL;
}
@@ -16490,7 +16490,7 @@ void free_tv(typval_T *varp)
func_unref(varp->vval.v_string);
/*FALLTHROUGH*/
case VAR_STRING:
- free(varp->vval.v_string);
+ xfree(varp->vval.v_string);
break;
case VAR_LIST:
list_unref(varp->vval.v_list);
@@ -16506,7 +16506,7 @@ void free_tv(typval_T *varp)
EMSG2(_(e_intern2), "free_tv()");
break;
}
- free(varp);
+ xfree(varp);
}
}
@@ -16520,12 +16520,12 @@ void clear_tv(typval_T *varp)
case VAR_FUNC:
func_unref(varp->vval.v_string);
if (varp->vval.v_string != empty_string) {
- free(varp->vval.v_string);
+ xfree(varp->vval.v_string);
}
varp->vval.v_string = NULL;
break;
case VAR_STRING:
- free(varp->vval.v_string);
+ xfree(varp->vval.v_string);
varp->vval.v_string = NULL;
break;
case VAR_LIST:
@@ -16929,7 +16929,7 @@ static void vars_clear_ext(hashtab_T *ht, int free_val)
if (free_val)
clear_tv(&v->di_tv);
if ((v->di_flags & DI_FLAGS_FIX) == 0)
- free(v);
+ xfree(v);
}
}
hash_clear(ht);
@@ -16946,7 +16946,7 @@ static void delete_var(hashtab_T *ht, hashitem_T *hi)
hash_remove(ht, hi);
clear_tv(&di->di_tv);
- free(di);
+ xfree(di);
}
/*
@@ -16962,7 +16962,7 @@ static void list_one_var(dictitem_T *v, char_u *prefix, int *first)
s = echo_string(&v->di_tv, &tofree, numbuf, current_copyID);
list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
s == NULL ? (char_u *)"" : s, first);
- free(tofree);
+ xfree(tofree);
}
static void
@@ -17057,7 +17057,7 @@ set_var (
*/
if (ht == &vimvarht) {
if (v->di_tv.v_type == VAR_STRING) {
- free(v->di_tv.vval.v_string);
+ xfree(v->di_tv.vval.v_string);
if (copy || tv->v_type != VAR_STRING)
v->di_tv.vval.v_string = vim_strsave(get_tv_string(tv));
else {
@@ -17094,7 +17094,7 @@ set_var (
v = xmalloc(sizeof(dictitem_T) + STRLEN(varname));
STRCPY(v->di_key, varname);
if (hash_add(ht, DI2HIKEY(v)) == FAIL) {
- free(v);
+ xfree(v);
return;
}
v->di_flags = 0;
@@ -17385,7 +17385,7 @@ void ex_echo(exarg_T *eap)
(void)msg_outtrans_len_attr(p, 1, echo_attr);
}
}
- free(tofree);
+ xfree(tofree);
}
clear_tv(&rettv);
arg = skipwhite(arg);
@@ -17631,7 +17631,7 @@ void ex_function(exarg_T *eap)
if (!aborting()) {
if (!eap->skip && fudi.fd_newkey != NULL)
EMSG2(_(e_dictkey), fudi.fd_newkey);
- free(fudi.fd_newkey);
+ xfree(fudi.fd_newkey);
return;
} else
eap->skip = TRUE;
@@ -17747,7 +17747,7 @@ void ex_function(exarg_T *eap)
for (int i = 0; i < newargs.ga_len; ++i)
if (STRCMP(((char_u **)(newargs.ga_data))[i], arg) == 0) {
EMSG2(_("E853: Duplicate argument name: %s"), arg);
- free(arg);
+ xfree(arg);
goto erret;
}
@@ -17853,7 +17853,7 @@ void ex_function(exarg_T *eap)
/* between ":append" and "." and between ":python <<EOF" and "EOF"
* don't check for ":endfunc". */
if (STRCMP(theline, skip_until) == 0) {
- free(skip_until);
+ xfree(skip_until);
skip_until = NULL;
}
} else {
@@ -17864,7 +17864,7 @@ void ex_function(exarg_T *eap)
/* Check for "endfunction". */
if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) {
if (line_arg == NULL)
- free(theline);
+ xfree(theline);
break;
}
@@ -17884,7 +17884,7 @@ void ex_function(exarg_T *eap)
p = skipwhite(p + 1);
}
p += eval_fname_script(p);
- free(trans_function_name(&p, TRUE, 0, NULL));
+ xfree(trans_function_name(&p, TRUE, 0, NULL));
if (*skipwhite(p) == '(') {
nesting++;
indent += 2;
@@ -17933,7 +17933,7 @@ void ex_function(exarg_T *eap)
* is an extra alloc/free. */
p = vim_strsave(theline);
if (line_arg == NULL)
- free(theline);
+ xfree(theline);
theline = p;
((char_u **)(newlines.ga_data))[newlines.ga_len++] = theline;
@@ -17978,7 +17978,7 @@ void ex_function(exarg_T *eap)
/* redefine existing function */
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));
- free(name);
+ xfree(name);
name = NULL;
}
} else {
@@ -18000,7 +18000,7 @@ void ex_function(exarg_T *eap)
/* Give the function a sequential number. Can only be used with a
* Funcref! */
- free(name);
+ xfree(name);
sprintf(numbuf, "%d", ++func_nr);
name = vim_strsave((char_u *)numbuf);
}
@@ -18020,7 +18020,7 @@ void ex_function(exarg_T *eap)
if (slen > plen && fnamecmp(p,
sourcing_name + slen - plen) == 0)
j = OK;
- free(scriptname);
+ xfree(scriptname);
}
if (j == FAIL) {
EMSG2(_(
@@ -18037,8 +18037,8 @@ void ex_function(exarg_T *eap)
/* add new dict entry */
fudi.fd_di = dictitem_alloc(fudi.fd_newkey);
if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) {
- free(fudi.fd_di);
- free(fp);
+ xfree(fudi.fd_di);
+ xfree(fp);
goto erret;
}
} else
@@ -18075,9 +18075,9 @@ erret:
ga_clear_strings(&newargs);
ga_clear_strings(&newlines);
ret_free:
- free(skip_until);
- free(fudi.fd_newkey);
- free(name);
+ xfree(skip_until);
+ xfree(fudi.fd_newkey);
+ xfree(name);
did_emsg |= saved_did_emsg;
need_wait_return |= saved_wait_return;
}
@@ -18389,7 +18389,7 @@ static int function_exists(char_u *name)
* "funcname(...", not "funcname!...". */
if (p != NULL && (*nm == NUL || *nm == '('))
n = translated_function_exists(p);
- free(p);
+ xfree(p);
return n;
}
@@ -18496,7 +18496,7 @@ void func_dump_profile(FILE *fd)
prof_sort_list(fd, sorttab, st_len, "SELF", TRUE);
}
- free(sorttab);
+ xfree(sorttab);
}
static void
@@ -18612,7 +18612,7 @@ script_autoload (
ret = TRUE;
}
- free(tofree);
+ xfree(tofree);
return ret;
}
@@ -18702,14 +18702,14 @@ void ex_delfunction(exarg_T *eap)
p = eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi);
- free(fudi.fd_newkey);
+ xfree(fudi.fd_newkey);
if (name == NULL) {
if (fudi.fd_dict != NULL && !eap->skip)
EMSG(_(e_funcref));
return;
}
if (!ends_excmd(*skipwhite(p))) {
- free(name);
+ xfree(name);
EMSG(_(e_trailing));
return;
}
@@ -18719,7 +18719,7 @@ void ex_delfunction(exarg_T *eap)
if (!eap->skip)
fp = find_func(name);
- free(name);
+ xfree(name);
if (!eap->skip) {
if (fp == NULL) {
@@ -18755,9 +18755,9 @@ static void func_free(ufunc_T *fp)
/* clear this function */
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));
- free(fp->uf_tml_count);
- free(fp->uf_tml_total);
- free(fp->uf_tml_self);
+ xfree(fp->uf_tml_count);
+ xfree(fp->uf_tml_total);
+ xfree(fp->uf_tml_self);
/* remove the function from the function hashtable */
hi = hash_find(&func_hashtab, UF2HIKEY(fp));
@@ -18766,7 +18766,7 @@ static void func_free(ufunc_T *fp)
else
hash_remove(&func_hashtab, hi);
- free(fp);
+ xfree(fp);
}
/*
@@ -19003,7 +19003,7 @@ call_user_func (
s = buf;
}
msg_puts(s);
- free(tofree);
+ xfree(tofree);
}
}
}
@@ -19090,7 +19090,7 @@ call_user_func (
s = buf;
}
smsg((char_u *)_("%s returning %s"), sourcing_name, s);
- free(tofree);
+ xfree(tofree);
}
}
msg_puts((char_u *)"\n"); /* don't overwrite this either */
@@ -19099,7 +19099,7 @@ call_user_func (
--no_wait_return;
}
- free(sourcing_name);
+ xfree(sourcing_name);
sourcing_name = save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
current_SID = save_current_SID;
@@ -19196,7 +19196,7 @@ free_funccal (
for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next)
clear_tv(&li->li_tv);
- free(fc);
+ xfree(fc);
}
/*
@@ -19327,7 +19327,7 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv)
clear_tv(current_funccal->rettv);
*current_funccal->rettv = *(typval_T *)rettv;
if (!is_cmd)
- free(rettv);
+ xfree(rettv);
}
}
@@ -19361,7 +19361,7 @@ char_u *get_return_cmd(void *rettv)
STRNCPY(IObuff + 8, s, IOSIZE - 8);
if (STRLEN(s) + 8 >= IOSIZE)
STRCPY(IObuff + IOSIZE - 4, "...");
- free(tofree);
+ xfree(tofree);
return vim_strsave(IObuff);
}
@@ -19549,16 +19549,16 @@ int read_viminfo_varlist(vir_T *virp, int writing)
* string. */
tv.v_type = VAR_STRING;
else {
- free(tv.vval.v_string);
+ xfree(tv.vval.v_string);
tv = *etv;
- free(etv);
+ xfree(etv);
}
}
set_var(virp->vir_line + 1, &tv, FALSE);
if (tv.v_type == VAR_STRING)
- free(tv.vval.v_string);
+ xfree(tv.vval.v_string);
else if (tv.v_type == VAR_DICT || tv.v_type == VAR_LIST)
clear_tv(&tv);
}
@@ -19604,7 +19604,7 @@ void write_viminfo_varlist(FILE *fp)
p = echo_string(&this_var->di_tv, &tofree, numbuf, 0);
if (p != NULL)
viminfo_writestring(fp, p);
- free(tofree);
+ xfree(tofree);
}
}
}
@@ -19642,10 +19642,10 @@ int store_session_globals(FILE *fd)
(this_var->di_tv.v_type == VAR_STRING) ? '"'
: ' ') < 0)
|| put_eol(fd) == FAIL) {
- free(p);
+ xfree(p);
return FAIL;
}
- free(p);
+ xfree(p);
} else if (this_var->di_tv.v_type == VAR_FLOAT
&& var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION) {
float_T f = this_var->di_tv.vval.v_float;
@@ -19676,7 +19676,7 @@ void last_set_msg(scid_T scriptID)
verbose_enter();
MSG_PUTS(_("\n\tLast set from "));
MSG_PUTS(p);
- free(p);
+ xfree(p);
verbose_leave();
}
}
@@ -19756,7 +19756,7 @@ repeat:
#endif
) {
*fnamep = expand_env_save(*fnamep);
- free(*bufp); /* free any allocated file name */
+ xfree(*bufp); /* free any allocated file name */
*bufp = *fnamep;
if (*fnamep == NULL)
return -1;
@@ -19776,7 +19776,7 @@ repeat:
/* FullName_save() is slow, don't use it when not needed. */
if (*p != NUL || !vim_isAbsName(*fnamep)) {
*fnamep = FullName_save(*fnamep, *p != NUL);
- free(*bufp); /* free any allocated file name */
+ xfree(*bufp); /* free any allocated file name */
*bufp = *fnamep;
if (*fnamep == NULL)
return -1;
@@ -19786,7 +19786,7 @@ repeat:
if (os_isdir(*fnamep)) {
/* Make room for one or two extra characters. */
*fnamep = vim_strnsave(*fnamep, (int)STRLEN(*fnamep) + 2);
- free(*bufp); /* free any allocated file name */
+ xfree(*bufp); /* free any allocated file name */
*bufp = *fnamep;
if (*fnamep == NULL)
return -1;
@@ -19822,7 +19822,7 @@ repeat:
if (s != NULL) {
*fnamep = s;
if (pbuf != NULL) {
- free(*bufp); /* free any allocated file name */
+ xfree(*bufp); /* free any allocated file name */
*bufp = pbuf;
pbuf = NULL;
}
@@ -19833,11 +19833,11 @@ repeat:
if (*dirname == '~') {
s = vim_strsave(dirname);
*fnamep = s;
- free(*bufp);
+ xfree(*bufp);
*bufp = s;
}
}
- free(pbuf);
+ xfree(pbuf);
}
}
@@ -19855,7 +19855,7 @@ repeat:
*fnamelen = (int)(tail - *fnamep);
if (*fnamelen == 0) {
/* Result is empty. Turn it into "." to make ":cd %:h" work. */
- free(*bufp);
+ xfree(*bufp);
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
*fnamelen = 1;
} else {
@@ -19940,13 +19940,13 @@ repeat:
s = do_string_sub(str, pat, sub, flags);
*fnamep = s;
*fnamelen = (int)STRLEN(s);
- free(*bufp);
+ xfree(*bufp);
*bufp = s;
didit = TRUE;
- free(sub);
- free(str);
+ xfree(sub);
+ xfree(str);
}
- free(pat);
+ xfree(pat);
}
/* after using ":s", repeat all the modifiers */
if (didit)
@@ -19956,7 +19956,7 @@ repeat:
if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S') {
p = vim_strsave_shellescape(*fnamep, false, false);
- free(*bufp);
+ xfree(*bufp);
*bufp = *fnamep = p;
*fnamelen = (int)STRLEN(p);
*usedlen += 2;
@@ -20099,7 +20099,7 @@ static inline Job *common_job_start(JobOptions opts, typval_T *rettv)
if (rettv->vval.v_number <= 0) {
if (rettv->vval.v_number == 0) {
EMSG(_(e_jobtblfull));
- free(opts.term_name);
+ xfree(opts.term_name);
free_term_job_data(data);
} else {
EMSG(_(e_jobexe));
@@ -20125,7 +20125,7 @@ static inline void free_term_job_data(TerminalJobData *data) {
data->self->internal_refcount--;
dict_unref(data->self);
}
- free(data);
+ xfree(data);
}
static inline bool is_user_job(Job *job)
@@ -20236,7 +20236,7 @@ static void on_job_exit(Job *job, int status, void *d)
static void term_write(char *buf, size_t size, void *data)
{
Job *job = ((TerminalJobData *)data)->job;
- WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, free);
+ WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree);
job_write(job, wbuf);
}
@@ -20310,7 +20310,7 @@ end:
// exit event, safe to free job data now
term_job_data_decref(ev->data);
}
- free(ev);
+ xfree(ev);
}
static void script_host_eval(char *name, typval_T *argvars, typval_T *rettv)
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index c686c5effa..c57861282d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -533,9 +533,9 @@ void ex_sort(exarg_T *eap)
beginline(BL_WHITE | BL_FIX);
sortend:
- free(nrs);
- free(sortbuf1);
- free(sortbuf2);
+ xfree(nrs);
+ xfree(sortbuf1);
+ xfree(sortbuf2);
vim_regfree(regmatch.regprog);
if (got_int)
EMSG(_(e_interr));
@@ -698,7 +698,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
for (extra = 0, l = line1; l <= line2; l++) {
str = vim_strsave(ml_get(l + extra));
ml_append(dest + l - line1, str, (colnr_T)0, FALSE);
- free(str);
+ xfree(str);
if (dest < line1)
extra++;
}
@@ -804,7 +804,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
* ml_append() */
p = vim_strsave(ml_get(line1));
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE);
- free(p);
+ xfree(p);
/* situation 2: skip already copied lines */
if (line1 == n)
@@ -827,7 +827,7 @@ static char_u *prevcmd = NULL; /* the previous command */
#if defined(EXITFREE)
void free_prev_shellcmd(void)
{
- free(prevcmd);
+ xfree(prevcmd);
}
#endif
@@ -878,7 +878,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
if (ins_prevcmd) {
if (prevcmd == NULL) {
EMSG(_(e_noprev));
- free(newcmd);
+ xfree(newcmd);
return;
}
len += (int)STRLEN(prevcmd);
@@ -891,7 +891,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
STRCAT(t, prevcmd);
p = t + STRLEN(t);
STRCAT(t, trailarg);
- free(newcmd);
+ xfree(newcmd);
newcmd = t;
/*
@@ -914,7 +914,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
}
} while (trailarg != NULL);
- free(prevcmd);
+ xfree(prevcmd);
prevcmd = newcmd;
if (bangredo) { /* put cmd in redo buffer for ! command */
@@ -924,7 +924,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
AppendToRedobuffLit(cmd, -1);
- free(cmd);
+ xfree(cmd);
AppendToRedobuff((char_u *)"\n");
bangredo = FALSE;
}
@@ -955,7 +955,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, FALSE, curbuf);
}
if (free_newcmd)
- free(newcmd);
+ xfree(newcmd);
}
/*
@@ -1076,7 +1076,7 @@ do_filter (
if (do_out) {
if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL) {
- free(cmd_buf);
+ xfree(cmd_buf);
goto error;
}
redraw_curbuf_later(VALID);
@@ -1100,7 +1100,7 @@ do_filter (
redraw_later_clear();
wait_return(FALSE);
}
- free(cmd_buf);
+ xfree(cmd_buf);
did_check_timestamps = FALSE;
need_check_timestamps = TRUE;
@@ -1197,8 +1197,8 @@ filterend:
os_remove((char *)itmp);
if (otmp != NULL)
os_remove((char *)otmp);
- free(itmp);
- free(otmp);
+ xfree(itmp);
+ xfree(otmp);
}
/*
@@ -1448,7 +1448,7 @@ read_viminfo (
verbose_leave();
}
- free(fname);
+ xfree(fname);
if (fp == NULL)
return FAIL;
@@ -1550,7 +1550,7 @@ void write_viminfo(char_u *file, int forceit)
* write the viminfo file then.
*/
if (*wp == 'a') {
- free(tempname);
+ xfree(tempname);
tempname = NULL;
break;
}
@@ -1586,7 +1586,7 @@ void write_viminfo(char_u *file, int forceit)
* "normal" temp file.
*/
if (fp_out == NULL) {
- free(tempname);
+ xfree(tempname);
if ((tempname = vim_tempname()) != NULL)
fp_out = mch_fopen((char *)tempname, WRITEBIN);
}
@@ -1639,8 +1639,8 @@ void write_viminfo(char_u *file, int forceit)
}
end:
- free(fname);
- free(tempname);
+ xfree(fname);
+ xfree(tempname);
}
/*
@@ -1721,7 +1721,7 @@ static void do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
&& (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT)))
copy_viminfo_marks(&vir, fp_out, count, eof, flags);
- free(vir.vir_line);
+ xfree(vir.vir_line);
if (vir.vir_conv.vc_type != CONV_NONE)
convert_setup(&vir.vir_conv, NULL, NULL);
}
@@ -1886,7 +1886,7 @@ viminfo_readstring (
if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != NUL) {
d = string_convert(&virp->vir_conv, retval, NULL);
if (d != NULL) {
- free(retval);
+ xfree(retval);
retval = d;
}
}
@@ -2000,8 +2000,8 @@ int rename_buffer(char_u *new_fname)
if (buf != NULL && !cmdmod.keepalt)
curwin->w_alt_fnum = buf->b_fnum;
}
- free(fname);
- free(sfname);
+ xfree(fname);
+ xfree(sfname);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
/* Change directories when the 'acd' option is set. */
do_autochdir();
@@ -2206,7 +2206,7 @@ int do_write(exarg_T *eap)
}
theend:
- free(free_fname);
+ xfree(free_fname);
return retval;
}
@@ -2279,7 +2279,7 @@ check_overwrite (
copy_option_part(&p, dir, MAXPATHL, ",");
}
swapname = makeswapname(fname, ffname, curbuf, dir);
- free(dir);
+ xfree(dir);
if (os_file_exists(swapname)) {
if (p_confirm || cmdmod.confirm) {
char_u buff[DIALOG_MSG_SIZE];
@@ -2289,18 +2289,18 @@ check_overwrite (
swapname);
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
!= VIM_YES) {
- free(swapname);
+ xfree(swapname);
return FAIL;
}
eap->forceit = TRUE;
} else {
EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"),
swapname);
- free(swapname);
+ xfree(swapname);
return FAIL;
}
}
- free(swapname);
+ xfree(swapname);
}
}
return OK;
@@ -2486,7 +2486,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,
retval = 1; /* error encountered */
theend:
- free(free_me);
+ xfree(free_me);
return retval;
}
@@ -2623,7 +2623,7 @@ do_ecmd (
}
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
did_set_swapcommand = TRUE;
- free(p);
+ xfree(p);
}
/*
@@ -2712,7 +2712,7 @@ do_ecmd (
goto theend;
}
if (aborting()) { /* autocmds may abort script processing */
- free(new_name);
+ xfree(new_name);
goto theend;
}
if (buf == curbuf) /* already in new buffer */
@@ -2737,7 +2737,7 @@ do_ecmd (
}
if (aborting()) { /* autocmds may abort script processing */
- free(new_name);
+ xfree(new_name);
goto theend;
}
/* Be careful again, like above. */
@@ -2775,7 +2775,7 @@ do_ecmd (
did_get_winopts = TRUE;
}
- free(new_name);
+ xfree(new_name);
au_new_curbuf = NULL;
} else
++curbuf->b_nwindows;
@@ -2849,7 +2849,7 @@ do_ecmd (
delbuf_msg(new_name); /* frees new_name */
goto theend;
}
- free(new_name);
+ xfree(new_name);
/* If autocommands change buffers under our fingers, forget about
* re-editing the file. Should do the buf_clear_file(), but perhaps
@@ -3040,7 +3040,7 @@ do_ecmd (
theend:
if (did_set_swapcommand)
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
- free(free_fname);
+ xfree(free_fname);
return retval;
}
@@ -3048,7 +3048,7 @@ static void delbuf_msg(char_u *name)
{
EMSG2(_("E143: Autocommands unexpectedly deleted new buffer %s"),
name == NULL ? (char_u *)"" : name);
- free(name);
+ xfree(name);
au_new_curbuf = NULL;
}
@@ -3140,7 +3140,7 @@ void ex_append(exarg_T *eap)
if ((p[0] == '.' && p[1] == NUL)
|| (!did_undo && u_save(lnum, lnum + 1 + (empty ? 1 : 0))
== FAIL)) {
- free(theline);
+ xfree(theline);
break;
}
@@ -3152,7 +3152,7 @@ void ex_append(exarg_T *eap)
ml_append(lnum, theline, (colnr_T)0, FALSE);
appended_lines_mark(lnum, 1L);
- free(theline);
+ xfree(theline);
++lnum;
if (empty) {
@@ -3481,7 +3481,7 @@ void do_sub(exarg_T *eap)
}
sub = old_sub;
} else {
- free(old_sub);
+ xfree(old_sub);
old_sub = vim_strsave(sub);
}
}
@@ -3742,7 +3742,7 @@ void do_sub(exarg_T *eap)
lnum += regmatch.startpos[0].lnum;
sub_firstlnum += regmatch.startpos[0].lnum;
nmatch -= regmatch.startpos[0].lnum;
- free(sub_firstline);
+ xfree(sub_firstline);
sub_firstline = NULL;
}
@@ -3846,7 +3846,7 @@ void do_sub(exarg_T *eap)
resp = getexmodeline('?', NULL, 0);
if (resp != NULL) {
typed = *resp;
- free(resp);
+ xfree(resp);
}
} else {
char_u *orig_line = NULL;
@@ -4061,7 +4061,7 @@ void do_sub(exarg_T *eap)
* line and continue in that one. */
if (nmatch > 1) {
sub_firstlnum += nmatch - 1;
- free(sub_firstline);
+ xfree(sub_firstline);
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
/* When going beyond the last line, stop substituting. */
if (sub_firstlnum <= line2)
@@ -4076,7 +4076,7 @@ void do_sub(exarg_T *eap)
if (skip_match) {
/* Already hit end of the buffer, sub_firstlnum is one
* less than what it ought to be. */
- free(sub_firstline);
+ xfree(sub_firstline);
sub_firstline = vim_strsave((char_u *)"");
copycol = 0;
}
@@ -4204,7 +4204,7 @@ skip:
}
sub_firstlnum = lnum;
- free(sub_firstline); /* free the temp buffer */
+ xfree(sub_firstline); /* free the temp buffer */
sub_firstline = new_start;
new_start = NULL;
matchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;
@@ -4234,8 +4234,8 @@ skip:
if (did_sub)
++sub_nlines;
- free(new_start); /* for when substitute was cancelled */
- free(sub_firstline); /* free the copy of the original line */
+ xfree(new_start); /* for when substitute was cancelled */
+ xfree(sub_firstline); /* free the copy of the original line */
sub_firstline = NULL;
}
@@ -4250,7 +4250,7 @@ skip:
changed_lines(first_line, 0, last_line - i, i);
}
- free(sub_firstline); /* may have to free allocated copy of the line */
+ xfree(sub_firstline); /* may have to free allocated copy of the line */
/* ":s/pat//n" doesn't move the cursor */
if (do_count)
@@ -4510,7 +4510,7 @@ void global_exe(char_u *cmd)
int read_viminfo_sub_string(vir_T *virp, int force)
{
if (force)
- free(old_sub);
+ xfree(old_sub);
if (force || old_sub == NULL)
old_sub = viminfo_readstring(virp, 1, TRUE);
return viminfo_readline(virp);
@@ -4527,7 +4527,7 @@ void write_viminfo_sub_string(FILE *fp)
#if defined(EXITFREE)
void free_old_sub(void)
{
- free(old_sub);
+ xfree(old_sub);
}
#endif
@@ -4739,7 +4739,7 @@ void ex_help(exarg_T *eap)
curwin->w_alt_fnum = alt_fnum;
erret:
- free(tag);
+ xfree(tag);
}
@@ -5003,7 +5003,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la
sizeof(char_u *), help_compare);
/* Delete more than TAG_MANY to reduce the size of the listing. */
while (*num_matches > TAG_MANY)
- free((*matches)[--*num_matches]);
+ xfree((*matches)[--*num_matches]);
}
return OK;
}
@@ -5165,7 +5165,7 @@ void fix_help_buffer(void)
if (fnamecmp(e1, ".txt") != 0
&& fnamecmp(e1, fname + 4) != 0) {
/* Not .txt and not .abx, remove it. */
- free(fnames[i1]);
+ xfree(fnames[i1]);
fnames[i1] = NULL;
continue;
}
@@ -5174,7 +5174,7 @@ void fix_help_buffer(void)
if (fnamecmp(e1, ".txt") == 0
&& fnamecmp(e2, fname + 4) == 0) {
/* use .abx instead of .txt */
- free(fnames[i1]);
+ xfree(fnames[i1]);
fnames[i1] = NULL;
}
}
@@ -5234,7 +5234,7 @@ void fix_help_buffer(void)
ml_append(lnum, cp, (colnr_T)0, FALSE);
if (cp != IObuff)
- free(cp);
+ xfree(cp);
++lnum;
}
fclose(fd);
@@ -5243,7 +5243,7 @@ void fix_help_buffer(void)
}
}
if (mustfree)
- free(rt);
+ xfree(rt);
}
break;
}
@@ -5310,7 +5310,7 @@ void ex_helptags(exarg_T *eap)
EW_FILE|EW_SILENT) == FAIL
|| filecount == 0) {
EMSG2("E151: No match: %s", NameBuff);
- free(dirname);
+ xfree(dirname);
return;
}
@@ -5372,7 +5372,7 @@ void ex_helptags(exarg_T *eap)
ga_clear(&ga);
FreeWild(filecount, files);
- free(dirname);
+ xfree(dirname);
}
static void
@@ -5722,7 +5722,7 @@ void ex_sign(exarg_T *eap)
next_sign_typenr = 1;
if (next_sign_typenr == start)
{
- free(sp);
+ xfree(sp);
EMSG(_("E612: Too many signs defined"));
return;
}
@@ -5755,7 +5755,7 @@ void ex_sign(exarg_T *eap)
if (STRNCMP(arg, "icon=", 5) == 0)
{
arg += 5;
- free(sp->sn_icon);
+ xfree(sp->sn_icon);
sp->sn_icon = vim_strnsave(arg, (int)(p - arg));
backslash_halve(sp->sn_icon);
}
@@ -5794,7 +5794,7 @@ void ex_sign(exarg_T *eap)
return;
}
- free(sp->sn_text);
+ xfree(sp->sn_text);
/* Allocate one byte more if we need to pad up
* with a space. */
len = (int)(p - arg + ((cells == 1) ? 1 : 0));
@@ -5983,7 +5983,7 @@ void ex_sign(exarg_T *eap)
sprintf((char *)cmd, "e +%" PRId64 " %s",
(int64_t)lnum, buf->b_fname);
do_cmdline_cmd(cmd);
- free(cmd);
+ xfree(cmd);
}
foldOpenCursor();
@@ -6076,14 +6076,14 @@ static void sign_list_defined(sign_T *sp)
*/
static void sign_undefine(sign_T *sp, sign_T *sp_prev)
{
- free(sp->sn_name);
- free(sp->sn_icon);
- free(sp->sn_text);
+ xfree(sp->sn_name);
+ xfree(sp->sn_icon);
+ xfree(sp->sn_text);
if (sp_prev == NULL)
first_sign = sp->sn_next;
else
sp_prev->sn_next = sp->sn_next;
- free(sp);
+ xfree(sp);
}
/*
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 177e404e35..463cc794c7 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -278,11 +278,11 @@ void do_debug(char_u *cmd)
DOCMD_VERBOSE|DOCMD_EXCRESET);
debug_break_level = n;
- free(cmdline);
+ xfree(cmdline);
}
lines_left = Rows - 1;
}
- free(cmdline);
+ xfree(cmdline);
--RedrawingDisabled;
--no_wait_return;
@@ -491,12 +491,12 @@ dbg_parsearg (
if (q == NULL)
return FAIL;
p = expand_env_save(q);
- free(q);
+ xfree(q);
if (p == NULL)
return FAIL;
if (*p != '*') {
bp->dbg_name = fix_fname(p);
- free(p);
+ xfree(p);
} else
bp->dbg_name = p;
}
@@ -526,10 +526,10 @@ void ex_breakadd(exarg_T *eap)
pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE);
if (pat != NULL) {
bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
- free(pat);
+ xfree(pat);
}
if (pat == NULL || bp->dbg_prog == NULL)
- free(bp->dbg_name);
+ xfree(bp->dbg_name);
else {
if (bp->dbg_lnum == 0) /* default line number is 1 */
bp->dbg_lnum = 1;
@@ -598,14 +598,14 @@ void ex_breakdel(exarg_T *eap)
best_lnum = bpi->dbg_lnum;
}
}
- free(bp->dbg_name);
+ xfree(bp->dbg_name);
}
if (todel < 0)
EMSG2(_("E161: Breakpoint not found: %s"), eap->arg);
else {
while (!GA_EMPTY(gap)) {
- free(DEBUGGY(gap, todel).dbg_name);
+ xfree(DEBUGGY(gap, todel).dbg_name);
vim_regfree(DEBUGGY(gap, todel).dbg_prog);
--gap->ga_len;
if (todel < gap->ga_len)
@@ -727,7 +727,7 @@ debuggy_find (
}
}
if (name != fname)
- free(name);
+ xfree(name);
return lnum;
}
@@ -759,7 +759,7 @@ void ex_profile(exarg_T *eap)
e = skipwhite(e);
if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) {
- free(profile_fname);
+ xfree(profile_fname);
profile_fname = expand_env_save_opt(e, true);
do_profiling = PROF_YES;
profile_set_wait(profile_zero());
@@ -1293,7 +1293,7 @@ buf_found:
set_curbuf(buf, DOBUF_GOTO);
theend:
- free(bufnrs);
+ xfree(bufnrs);
return ret;
}
@@ -1450,7 +1450,7 @@ do_arglist (
break;
regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL) {
- free(p);
+ xfree(p);
break;
}
@@ -1459,7 +1459,7 @@ do_arglist (
if (vim_regexec(&regmatch, alist_name(&ARGLIST[match]),
(colnr_T)0)) {
didone = TRUE;
- free(ARGLIST[match].ae_fname);
+ xfree(ARGLIST[match].ae_fname);
memmove(ARGLIST + match, ARGLIST + match + 1,
(ARGCOUNT - match - 1) * sizeof(aentry_T));
--ALIST(curwin)->al_ga.ga_len;
@@ -1469,7 +1469,7 @@ do_arglist (
}
vim_regfree(regmatch.regprog);
- free(p);
+ xfree(p);
if (!didone)
EMSG2(_(e_nomatch2), ((char_u **)new_ga.ga_data)[i]);
}
@@ -1487,7 +1487,7 @@ do_arglist (
if (what == AL_ADD) {
(void)alist_add_list(exp_count, exp_files, after);
- free(exp_files);
+ xfree(exp_files);
} else /* what == AL_SET */
alist_set(ALIST(curwin), exp_count, exp_files, FALSE, NULL, 0);
}
@@ -1683,7 +1683,7 @@ void do_argfile(exarg_T *eap, int argn)
if (P_HID(curbuf)) {
p = fix_fname(alist_name(&ARGLIST[argn]));
other = otherfile(p);
- free(p);
+ xfree(p);
}
if ((!P_HID(curbuf) || !other)
&& check_changed(curbuf, CCGD_AW
@@ -1793,7 +1793,7 @@ void ex_argdelete(exarg_T *eap)
EMSG(_(e_invarg));
else {
for (int i = eap->line1; i <= eap->line2; ++i)
- free(ARGLIST[i - 1].ae_fname);
+ xfree(ARGLIST[i - 1].ae_fname);
memmove(ARGLIST + eap->line1 - 1, ARGLIST + eap->line2,
(size_t)((ARGCOUNT - eap->line2) * sizeof(aentry_T)));
ALIST(curwin)->al_ga.ga_len -= n;
@@ -1858,7 +1858,7 @@ void ex_listdo(exarg_T *eap)
set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
do_argfile(eap, i);
set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
- free(p_shm_save);
+ xfree(p_shm_save);
}
if (curwin->w_arg_idx != i)
break;
@@ -1915,7 +1915,7 @@ void ex_listdo(exarg_T *eap)
set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
- free(p_shm_save);
+ xfree(p_shm_save);
/* If autocommands took us elsewhere, quit here */
if (curbuf->b_fnum != next_fnum)
@@ -2011,7 +2011,7 @@ void ex_compiler(exarg_T *eap)
sprintf((char *)buf, "compiler/%s.vim", eap->arg);
if (source_runtime(buf, TRUE) == FAIL)
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
- free(buf);
+ xfree(buf);
do_cmdline_cmd((char_u *)":delcommand CompilerSet");
@@ -2025,7 +2025,7 @@ void ex_compiler(exarg_T *eap)
if (old_cur_comp != NULL) {
set_internal_string_var((char_u *)"g:current_compiler",
old_cur_comp);
- free(old_cur_comp);
+ xfree(old_cur_comp);
} else
do_unlet((char_u *)"g:current_compiler", TRUE);
}
@@ -2135,8 +2135,8 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback,
}
}
}
- free(buf);
- free(rtp_copy);
+ xfree(buf);
+ xfree(rtp_copy);
if (p_verbose > 0 && !did_one && name != NULL) {
verbose_enter();
smsg((char_u *)_("not found in 'runtimepath': \"%s\""), name);
@@ -2273,7 +2273,7 @@ do_source (
if (p == NULL)
return retval;
fname_exp = fix_fname(p);
- free(p);
+ xfree(p);
if (fname_exp == NULL)
return retval;
if (os_isdir(fname_exp)) {
@@ -2391,7 +2391,7 @@ do_source (
p = string_convert(&cookie.conv, firstline + 3, NULL);
if (p == NULL)
p = vim_strsave(firstline + 3);
- free(firstline);
+ xfree(firstline);
firstline = p;
}
@@ -2518,12 +2518,12 @@ do_source (
if (l_do_profiling == PROF_YES)
prof_child_exit(&wait_start); /* leaving a child now */
fclose(cookie.fp);
- free(cookie.nextline);
- free(firstline);
+ xfree(cookie.nextline);
+ xfree(firstline);
convert_setup(&cookie.conv, NULL, NULL);
theend:
- free(fname_exp);
+ xfree(fname_exp);
return retval;
}
@@ -2577,7 +2577,7 @@ char_u *get_scriptname(scid_T id)
# if defined(EXITFREE)
void free_scriptnames()
{
-# define FREE_SCRIPTNAME(item) free((item)->sn_name)
+# define FREE_SCRIPTNAME(item) xfree((item)->sn_name)
GA_DEEP_CLEAR(&script_items, scriptitem_T, FREE_SCRIPTNAME);
}
# endif
@@ -2636,7 +2636,7 @@ char_u *getsourceline(int c, void *cookie, int indent)
ga_concat(&ga, line);
ga_concat(&ga, p + 1);
for (;; ) {
- free(sp->nextline);
+ xfree(sp->nextline);
sp->nextline = get_one_sourceline(sp);
if (sp->nextline == NULL)
break;
@@ -2651,7 +2651,7 @@ char_u *getsourceline(int c, void *cookie, int indent)
ga_concat(&ga, p + 1);
}
ga_append(&ga, NUL);
- free(line);
+ xfree(line);
line = ga.ga_data;
}
}
@@ -2662,7 +2662,7 @@ char_u *getsourceline(int c, void *cookie, int indent)
/* Convert the encoding of the script line. */
s = string_convert(&sp->conv, line, NULL);
if (s != NULL) {
- free(line);
+ xfree(line);
line = s;
}
}
@@ -2771,7 +2771,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp)
if (have_read)
return (char_u *)ga.ga_data;
- free(ga.ga_data);
+ xfree(ga.ga_data);
return NULL;
}
@@ -2874,7 +2874,7 @@ void ex_scriptencoding(exarg_T *eap)
convert_setup(&sp->conv, name, p_enc);
if (name != eap->arg)
- free(name);
+ xfree(name);
}
/*
@@ -3192,7 +3192,7 @@ static char_u **find_locales(void)
GA_APPEND(char_u *, &locales_ga, loc);
loc = (char_u *)strtok(NULL, "\n");
}
- free(locale_a);
+ xfree(locale_a);
// Guarantee that .ga_data is NULL terminated
ga_grow(&locales_ga, 1);
((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
@@ -3205,8 +3205,8 @@ void free_locales(void)
int i;
if (locales != NULL) {
for (i = 0; locales[i] != NULL; i++)
- free(locales[i]);
- free(locales);
+ xfree(locales[i]);
+ xfree(locales);
locales = NULL;
}
}
@@ -3260,7 +3260,7 @@ static void script_host_execute(char *name, exarg_T *eap)
(void)eval_call_provider(name, "execute", args);
}
- free(script);
+ xfree(script);
}
static void script_host_execute_file(char *name, exarg_T *eap)
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index ed0f678e84..f7f6b84e6e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -104,7 +104,7 @@ typedef struct {
linenr_T lnum; /* sourcing_lnum of the line */
} wcmd_T;
-#define FREE_WCMD(wcmd) free((wcmd)->line)
+#define FREE_WCMD(wcmd) xfree((wcmd)->line)
/*
* Structure used to store info for line position in a while or for loop.
@@ -458,7 +458,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) {
/* Each '|' separated command is stored separately in lines_ga, to
* be able to jump to it. Don't use next_cmdline now. */
- free(cmdline_copy);
+ xfree(cmdline_copy);
cmdline_copy = NULL;
/* Check if a function has returned or, unless it has an unclosed
@@ -554,7 +554,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
* Keep the first typed line. Clear it when more lines are typed.
*/
if (flags & DOCMD_KEEPLINE) {
- free(repeat_cmdline);
+ xfree(repeat_cmdline);
if (count == 0)
repeat_cmdline = vim_strsave(next_cmdline);
else
@@ -628,7 +628,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
current_line = cmd_loop_cookie.current_line;
if (next_cmdline == NULL) {
- free(cmdline_copy);
+ xfree(cmdline_copy);
cmdline_copy = NULL;
/*
* If the command was typed, remember it for the ':' register.
@@ -636,7 +636,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
*/
if (getline_equal(fgetline, cookie, getexline)
&& new_last_cmdline != NULL) {
- free(last_cmdline);
+ xfree(last_cmdline);
last_cmdline = new_last_cmdline;
new_last_cmdline = NULL;
}
@@ -777,7 +777,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
|| cstack.cs_idx >= 0
|| (flags & DOCMD_REPEAT)));
- free(cmdline_copy);
+ xfree(cmdline_copy);
did_emsg_syntax = FALSE;
GA_DEEP_CLEAR(&lines_ga, wcmd_T, FREE_WCMD);
@@ -875,15 +875,15 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
do {
next = messages->next;
emsg(messages->msg);
- free(messages->msg);
- free(messages);
+ xfree(messages->msg);
+ xfree(messages);
messages = next;
} while (messages != NULL);
} else if (p != NULL) {
emsg(p);
- free(p);
+ xfree(p);
}
- free(sourcing_name);
+ xfree(sourcing_name);
sourcing_name = saved_sourcing_name;
sourcing_lnum = saved_sourcing_lnum;
}
@@ -1459,7 +1459,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
p = vim_strnsave(ea.cmd, p - ea.cmd);
int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
- free(p);
+ xfree(p);
if (ret && !aborting()) {
p = find_command(&ea, NULL);
}
@@ -3285,7 +3285,7 @@ static void ex_script_ni(exarg_T *eap)
if (!eap->skip)
ex_ni(eap);
else
- free(script_get(eap, eap->arg));
+ xfree(script_get(eap, eap->arg));
}
/*
@@ -3400,7 +3400,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
msg_make(p);
/* 'eap->cmd' is not set here, because it is not used at CMD_make */
- free(*cmdlinep);
+ xfree(*cmdlinep);
*cmdlinep = new_cmdline;
p = new_cmdline;
}
@@ -3464,7 +3464,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
char_u *l = repl;
repl = expand_env_save(repl);
- free(l);
+ xfree(l);
}
/* Need to escape white space et al. with a backslash.
@@ -3500,7 +3500,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
for (l = repl; *l; ++l)
if (vim_strchr(ESCAPE_CHARS, *l) != NULL) {
l = vim_strsave_escaped(repl, ESCAPE_CHARS);
- free(repl);
+ xfree(repl);
repl = l;
break;
}
@@ -3512,12 +3512,12 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
char_u *l;
l = vim_strsave_escaped(repl, (char_u *)"!");
- free(repl);
+ xfree(repl);
repl = l;
}
p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
- free(repl);
+ xfree(repl);
}
/*
@@ -3595,7 +3595,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
if (p != NULL) {
(void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
p, cmdlinep);
- free(p);
+ xfree(p);
}
}
}
@@ -3649,7 +3649,7 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl,
eap->arg = new_cmdline + (eap->arg - *cmdlinep);
if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command)
eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep);
- free(*cmdlinep);
+ xfree(*cmdlinep);
*cmdlinep = new_cmdline;
return src;
@@ -4141,9 +4141,9 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep,
goto fail;
}
- free(cmd->uc_rep);
+ xfree(cmd->uc_rep);
cmd->uc_rep = NULL;
- free(cmd->uc_compl_arg);
+ xfree(cmd->uc_compl_arg);
cmd->uc_compl_arg = NULL;
break;
}
@@ -4177,8 +4177,8 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep,
return OK;
fail:
- free(rep_buf);
- free(compl_arg);
+ xfree(rep_buf);
+ xfree(compl_arg);
return FAIL;
}
@@ -4531,9 +4531,9 @@ void ex_comclear(exarg_T *eap)
}
static void free_ucmd(ucmd_T* cmd) {
- free(cmd->uc_name);
- free(cmd->uc_rep);
- free(cmd->uc_compl_arg);
+ xfree(cmd->uc_name);
+ xfree(cmd->uc_rep);
+ xfree(cmd->uc_compl_arg);
}
/*
@@ -4569,9 +4569,9 @@ static void ex_delcommand(exarg_T *eap)
return;
}
- free(cmd->uc_name);
- free(cmd->uc_rep);
- free(cmd->uc_compl_arg);
+ xfree(cmd->uc_name);
+ xfree(cmd->uc_rep);
+ xfree(cmd->uc_compl_arg);
--gap->ga_len;
@@ -4937,8 +4937,8 @@ static void do_ucmd(exarg_T *eap)
(void)do_cmdline(buf, eap->getline, eap->cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
current_SID = save_current_SID;
- free(buf);
- free(split_buf);
+ xfree(buf);
+ xfree(split_buf);
}
static char_u *get_user_command_name(int idx)
@@ -5064,11 +5064,11 @@ static void ex_colorscheme(exarg_T *eap)
++emsg_off;
p = eval_to_string(expr, NULL, FALSE);
--emsg_off;
- free(expr);
+ xfree(expr);
if (p != NULL) {
MSG(p);
- free(p);
+ xfree(p);
} else
MSG("default");
} else if (load_colors(eap->arg) == FAIL)
@@ -5468,7 +5468,7 @@ static void ex_goto(exarg_T *eap)
*/
void alist_clear(alist_T *al)
{
-# define FREE_AENTRY_FNAME(arg) free(arg->ae_fname)
+# define FREE_AENTRY_FNAME(arg) xfree(arg->ae_fname)
GA_DEEP_CLEAR(&al->al_ga, aentry_T, FREE_AENTRY_FNAME);
}
@@ -5490,7 +5490,7 @@ void alist_unlink(alist_T *al)
{
if (al != &global_alist && --al->al_refcount <= 0) {
alist_clear(al);
- free(al);
+ xfree(al);
}
}
@@ -5556,7 +5556,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
/* When adding many buffers this can take a long time. Allow
* interrupting here. */
while (i < count)
- free(files[i++]);
+ xfree(files[i++]);
break;
}
@@ -5568,7 +5568,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
alist_add(al, files[i], use_curbuf ? 2 : 1);
os_breakcheck();
}
- free(files);
+ xfree(files);
}
if (al == &global_alist)
@@ -5729,7 +5729,7 @@ void ex_splitview(exarg_T *eap)
theend:
- free(fname);
+ xfree(fname);
}
/*
@@ -5908,7 +5908,7 @@ static void ex_find(exarg_T *eap)
* appears several times in the path. */
count = eap->line2;
while (fname != NULL && --count > 0) {
- free(fname);
+ xfree(fname);
fname = find_file_in_path(NULL, 0, FNAME_MESS,
FALSE, curbuf->b_ffname);
}
@@ -5917,7 +5917,7 @@ static void ex_find(exarg_T *eap)
if (fname != NULL) {
eap->arg = fname;
do_exedit(eap, NULL);
- free(fname);
+ xfree(fname);
}
}
@@ -6236,10 +6236,10 @@ static char_u *prev_dir = NULL;
#if defined(EXITFREE)
void free_cd_dir(void)
{
- free(prev_dir);
+ xfree(prev_dir);
prev_dir = NULL;
- free(globaldir);
+ xfree(globaldir);
globaldir = NULL;
}
@@ -6251,7 +6251,7 @@ void free_cd_dir(void)
*/
void post_chdir(int local)
{
- free(curwin->w_localdir);
+ xfree(curwin->w_localdir);
curwin->w_localdir = NULL;
if (local) {
/* If still in global directory, need to remember current
@@ -6264,7 +6264,7 @@ void post_chdir(int local)
} else {
/* We are now in the global directory, no need to remember its
* name. */
- free(globaldir);
+ xfree(globaldir);
globaldir = NULL;
}
@@ -6330,7 +6330,7 @@ void ex_cd(exarg_T *eap)
if (KeyTyped || p_verbose >= 5)
ex_pwd(eap);
}
- free(tofree);
+ xfree(tofree);
}
}
@@ -6733,7 +6733,7 @@ static void ex_redir(exarg_T *eap)
return;
redir_fd = open_exfile(fname, eap->forceit, mode);
- free(fname);
+ xfree(fname);
} else if (*arg == '@') {
/* redirect to a register a-z (resp. A-Z for appending) */
close_redir();
@@ -6970,7 +6970,7 @@ static void ex_mkrc(exarg_T *eap)
shorten_fnames(TRUE);
}
}
- free(dirnow);
+ xfree(dirnow);
} else {
failed |= (put_view(fd, curwin, !using_vdir, flagp,
-1) == FAIL);
@@ -6999,14 +6999,14 @@ static void ex_mkrc(exarg_T *eap)
tbuf = xmalloc(MAXPATHL);
if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK)
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
- free(tbuf);
+ xfree(tbuf);
}
#ifdef MKSESSION_NL
mksession_nl = FALSE;
#endif
}
- free(viewFile);
+ xfree(viewFile);
}
int vim_mkdir_emsg(char_u *name, int prot)
@@ -7189,7 +7189,7 @@ static void ex_normal(exarg_T *eap)
State = save_State;
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
- free(arg);
+ xfree(arg);
}
/*
@@ -7609,7 +7609,7 @@ eval_vars (
* postponed to avoid a delay when <afile> is not used. */
autocmd_fname_full = TRUE;
result = FullName_save(autocmd_fname, FALSE);
- free(autocmd_fname);
+ xfree(autocmd_fname);
autocmd_fname = result;
}
if (result == NULL) {
@@ -7686,7 +7686,7 @@ eval_vars (
result = NULL;
} else
result = vim_strnsave(result, resultlen);
- free(resultbuf);
+ xfree(resultbuf);
return result;
}
@@ -7772,7 +7772,7 @@ char_u *expand_sfile(char_u *arg)
if (errormsg != NULL) {
if (*errormsg)
emsg(errormsg);
- free(result);
+ xfree(result);
return NULL;
}
if (repl == NULL) { /* no match (cannot happen) */
@@ -7785,8 +7785,8 @@ char_u *expand_sfile(char_u *arg)
STRCPY(newres + (p - result), repl);
len = (int)STRLEN(newres);
STRCAT(newres, p + srclen);
- free(repl);
- free(result);
+ xfree(repl);
+ xfree(result);
result = newres;
p = newres + len; /* continue after the match */
}
@@ -7850,10 +7850,10 @@ makeopens (
if (fputs("cd ", fd) < 0
|| ses_put_fname(fd, sname, &ssop_flags) == FAIL
|| put_eol(fd) == FAIL) {
- free(sname);
+ xfree(sname);
return FAIL;
}
- free(sname);
+ xfree(sname);
}
/*
@@ -8434,10 +8434,10 @@ ses_arglist (
}
if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
|| put_eol(fd) == FAIL) {
- free(buf);
+ xfree(buf);
return FAIL;
}
- free(buf);
+ xfree(buf);
}
}
return OK;
@@ -8491,11 +8491,11 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
/* escape special characters */
p = vim_strsave_fnameescape(sname, FALSE);
- free(sname);
+ xfree(sname);
/* write the result */
bool retval = fputs((char *)p, fd) < 0 ? FAIL : OK;
- free(p);
+ xfree(p);
return retval;
}
@@ -8511,7 +8511,7 @@ static void ex_loadview(exarg_T *eap)
if (do_source(fname, FALSE, DOSO_NONE) == FAIL) {
EMSG2(_(e_notopen), fname);
}
- free(fname);
+ xfree(fname);
}
}
@@ -8564,7 +8564,7 @@ static char_u *get_view_file(int c)
*s++ = c;
STRCPY(s, ".vim");
- free(sname);
+ xfree(sname);
return retval;
}
@@ -8829,7 +8829,7 @@ static void ex_match(exarg_T *eap)
c = *end;
*end = NUL;
match_add(curwin, g, p + 1, 10, id, NULL);
- free(g);
+ xfree(g);
*end = c;
}
}
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index d2774804f8..5ed7a35209 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -281,8 +281,8 @@ static void free_msglist(struct msglist *l)
messages = l;
while (messages != NULL) {
next = messages->next;
- free(messages->msg);
- free(messages);
+ xfree(messages->msg);
+ xfree(messages);
messages = next;
}
}
@@ -505,7 +505,7 @@ static int throw_exception(void *value, int type, char_u *cmdname)
return OK;
nomem:
- free(excp);
+ xfree(excp);
suppress_errthrow = TRUE;
EMSG(_(e_outofmem));
fail:
@@ -550,14 +550,14 @@ static void discard_exception(except_T *excp, int was_finished)
else
verbose_leave();
STRCPY(IObuff, saved_IObuff);
- free(saved_IObuff);
+ xfree(saved_IObuff);
}
if (excp->type != ET_INTERRUPT)
- free(excp->value);
+ xfree(excp->value);
if (excp->type == ET_ERROR)
free_msglist(excp->messages);
- free(excp->throw_name);
- free(excp);
+ xfree(excp->throw_name);
+ xfree(excp);
}
/*
@@ -727,9 +727,9 @@ static void report_pending(int action, int pending, void *value)
msg_silent = save_msg_silent;
if (pending == CSTP_RETURN)
- free(s);
+ xfree(s);
else if (pending & CSTP_THROW)
- free(mesg);
+ xfree(mesg);
}
/*
@@ -1165,7 +1165,7 @@ void ex_throw(exarg_T *eap)
* not throw. */
if (!eap->skip && value != NULL) {
if (throw_exception(value, ET_USER, NULL) == FAIL)
- free(value);
+ xfree(value);
else
do_throw(eap->cstack);
}
@@ -1977,7 +1977,7 @@ int cleanup_conditionals(struct condstack *cstack, int searched_cond, int inclus
elem = cstack->cs_emsg_silent_list;
cstack->cs_emsg_silent_list = elem->next;
emsg_silent = elem->saved_emsg_silent;
- free(elem);
+ xfree(elem);
cstack->cs_flags[idx] &= ~CSF_SILENT;
}
if (stop)
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 6b74e85acb..7dac4a9565 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -354,7 +354,7 @@ getcmdline (
&& c != K_KPAGEDOWN && c != K_KPAGEUP
&& c != K_LEFT && c != K_RIGHT
&& (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) {
- free(lookfor);
+ xfree(lookfor);
lookfor = NULL;
}
@@ -593,7 +593,7 @@ getcmdline (
realloc_cmdbuff(len + 1);
ccline.cmdlen = len;
STRCPY(ccline.cmdbuff, p);
- free(p);
+ xfree(p);
/* Restore the cursor or use the position set with
* set_cmdline_pos(). */
@@ -825,7 +825,7 @@ getcmdline (
)
goto cmdline_not_changed;
- free(ccline.cmdbuff); /* no commandline to return */
+ xfree(ccline.cmdbuff); /* no commandline to return */
ccline.cmdbuff = NULL;
if (!cmd_silent) {
if (cmdmsg_rl)
@@ -1193,7 +1193,7 @@ getcmdline (
int len;
int old_firstc;
- free(ccline.cmdbuff);
+ xfree(ccline.cmdbuff);
xpc.xp_context = EXPAND_NOTHING;
if (hiscnt == hislen)
p = lookfor; /* back to the old one */
@@ -1476,13 +1476,13 @@ returncmd:
add_to_history(histype, ccline.cmdbuff, TRUE,
histype == HIST_SEARCH ? firstc : NUL);
if (firstc == ':') {
- free(new_last_cmdline);
+ xfree(new_last_cmdline);
new_last_cmdline = vim_strsave(ccline.cmdbuff);
}
}
if (gotesc) { /* abandon command line */
- free(ccline.cmdbuff);
+ xfree(ccline.cmdbuff);
ccline.cmdbuff = NULL;
if (msg_scrolled == 0)
compute_cmdrow();
@@ -1958,7 +1958,7 @@ static void realloc_cmdbuff(int len)
* there, thus copy up to the NUL and add a NUL. */
memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen);
ccline.cmdbuff[ccline.cmdlen] = NUL;
- free(p);
+ xfree(p);
if (ccline.xpc != NULL
&& ccline.xpc->xp_pattern != NULL
@@ -1978,7 +1978,7 @@ static char_u *arshape_buf = NULL;
# if defined(EXITFREE)
void free_cmdline_buf(void)
{
- free(arshape_buf);
+ xfree(arshape_buf);
}
# endif
@@ -2017,7 +2017,7 @@ static void draw_cmdline(int start, int len)
if (len * 2 + 2 > buflen) {
/* Re-allocate the buffer. We keep it around to avoid a lot of
* alloc()/free() calls. */
- free(arshape_buf);
+ xfree(arshape_buf);
buflen = len * 2 + 2;
arshape_buf = xmalloc(buflen);
}
@@ -2291,7 +2291,7 @@ char_u *save_cmdline_alloc(void)
void restore_cmdline_alloc(char_u *p)
{
restore_cmdline((struct cmdline_info *)p);
- free(p);
+ xfree(p);
}
/*
@@ -2368,7 +2368,7 @@ cmdline_paste (
cmdline_paste_str(p, literally);
if (allocated)
- free(arg);
+ xfree(arg);
return OK;
}
@@ -2616,7 +2616,7 @@ nextwild (
p2 = ExpandOne(xp, p1,
vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
use_options, type);
- free(p1);
+ xfree(p1);
/* longest match: make sure it is not shorter, happens with :help */
if (p2 != NULL && type == WILD_LONGEST) {
for (j = 0; j < xp->xp_pattern_len; ++j)
@@ -2624,7 +2624,7 @@ nextwild (
|| ccline.cmdbuff[i + j] == '?')
break;
if ((int)STRLEN(p2) < j) {
- free(p2);
+ xfree(p2);
p2 = NULL;
}
}
@@ -2644,7 +2644,7 @@ nextwild (
ccline.cmdlen += difflen;
ccline.cmdpos += difflen;
}
- free(p2);
+ xfree(p2);
redrawcmd();
cursorcmd();
@@ -2755,7 +2755,7 @@ ExpandOne (
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
- free(orig_save);
+ xfree(orig_save);
orig_save = NULL;
}
findex = 0;
@@ -2764,7 +2764,7 @@ ExpandOne (
return NULL;
if (xp->xp_numfiles == -1) {
- free(orig_save);
+ xfree(orig_save);
orig_save = orig;
orig_saved = TRUE;
@@ -2872,7 +2872,7 @@ ExpandOne (
/* Free "orig" if it wasn't stored in "orig_save". */
if (!orig_saved)
- free(orig);
+ xfree(orig);
return ss;
}
@@ -2930,11 +2930,11 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o
/* for ":set path=" we need to escape spaces twice */
if (xp->xp_backslash == XP_BS_THREE) {
p = vim_strsave_escaped(files[i], (char_u *)" ");
- free(files[i]);
+ xfree(files[i]);
files[i] = p;
#if defined(BACKSLASH_IN_FILENAME)
p = vim_strsave_escaped(files[i], (char_u *)" ");
- free(files[i]);
+ xfree(files[i]);
files[i] = p;
#endif
}
@@ -2943,7 +2943,7 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o
#else
p = vim_strsave_fnameescape(files[i], xp->xp_shell);
#endif
- free(files[i]);
+ xfree(files[i]);
files[i] = p;
/* If 'str' starts with "\~", replace "~" at start of
@@ -2964,7 +2964,7 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o
*/
for (i = 0; i < numfiles; ++i) {
p = vim_strsave_escaped(files[i], (char_u *)"\\|\"");
- free(files[i]);
+ xfree(files[i]);
files[i] = p;
}
}
@@ -2998,7 +2998,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell) FUNC_ATTR_NONNULL_RET
/* For csh and similar shells need to put two backslashes before '!'.
* One is taken by Vim, one by the shell. */
char_u *s = vim_strsave_escaped(p, (char_u *)"!");
- free(p);
+ xfree(p);
p = s;
}
#endif
@@ -3020,7 +3020,7 @@ static void escape_fname(char_u **pp)
char_u *p = xmalloc(STRLEN(*pp) + 2);
p[0] = '\\';
STRCPY(p + 1, *pp);
- free(*pp);
+ xfree(*pp);
*pp = p;
}
@@ -3036,7 +3036,7 @@ void tilde_replace(char_u *orig_pat, int num_files, char_u **files)
if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) {
for (i = 0; i < num_files; ++i) {
p = home_replace_save(NULL, files[i]);
- free(files[i]);
+ xfree(files[i]);
files[i] = p;
}
}
@@ -3154,8 +3154,8 @@ static int showmatches(expand_T *xp, int wildmenu)
halved_slash = backslash_halve_save(
exp_path != NULL ? exp_path : files_found[k]);
j = os_isdir(halved_slash);
- free(exp_path);
- free(halved_slash);
+ xfree(exp_path);
+ xfree(halved_slash);
} else
/* Expansion was done here, file names are literal. */
j = os_isdir(files_found[k]);
@@ -3515,7 +3515,7 @@ expand_cmdline (
*matchcount = 0;
*matches = NULL;
}
- free(file_str);
+ xfree(file_str);
return EXPAND_OK;
}
@@ -3610,7 +3610,7 @@ ExpandFromContext (
/* Expand wildcards, supporting %:h and the like. */
ret = expand_wildcards_eval(&pat, num_file, file, flags);
if (free_pat)
- free(pat);
+ xfree(pat);
return ret;
}
@@ -3887,9 +3887,9 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
STRMOVE(s, s + l);
((char_u **)ga.ga_data)[ga.ga_len++] = s;
} else
- free(s);
+ xfree(s);
}
- free(*file);
+ xfree(*file);
}
}
if (*e != NUL)
@@ -3898,10 +3898,10 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
*file = ga.ga_data;
*num_file = ga.ga_len;
- free(buf);
- free(pat);
+ xfree(buf);
+ xfree(pat);
if (mustfree)
- free(path);
+ xfree(path);
}
/*
@@ -3946,7 +3946,7 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
if (ccline.cmdbuff != NULL)
ccline.cmdbuff[ccline.cmdlen] = keep;
- free(args[0]);
+ xfree(args[0]);
return ret;
}
@@ -3986,7 +3986,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file,
if (*e != NUL)
++e;
}
- free(retstr);
+ xfree(retstr);
*file = ga.ga_data;
*num_file = ga.ga_len;
return OK;
@@ -4039,7 +4039,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
char_u *s = xmalloc(size);
snprintf((char *)s, size, "%s/%s*.vim", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
- free(s);
+ xfree(s);
}
for (int i = 0; i < ga.ga_len; i++) {
@@ -4108,7 +4108,7 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
}
}
- free(buf);
+ xfree(buf);
}
@@ -4210,7 +4210,7 @@ void init_history(void)
if (i >= 0) /* copy newest entries */
temp[i] = history[type][j];
else { /* remove older entries */
- free(history[type][j].hisstr);
+ xfree(history[type][j].hisstr);
history[type][j].hisstr = NULL;
}
if (--j < 0)
@@ -4220,7 +4220,7 @@ void init_history(void)
}
hisidx[type] = newlen - 1;
}
- free(history[type]);
+ xfree(history[type]);
history[type] = temp;
}
}
@@ -4347,7 +4347,7 @@ add_to_history (
if (maptick == last_maptick) {
/* Current line is from the same mapping, remove it */
hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];
- free(hisptr->hisstr);
+ xfree(hisptr->hisstr);
clear_hist_entry(hisptr);
--hisnum[histype];
if (--hisidx[HIST_SEARCH] < 0)
@@ -4359,7 +4359,7 @@ add_to_history (
if (++hisidx[histype] == hislen)
hisidx[histype] = 0;
hisptr = &history[histype][hisidx[histype]];
- free(hisptr->hisstr);
+ xfree(hisptr->hisstr);
/* Store the separator after the NUL of the string. */
len = (int)STRLEN(new_entry);
@@ -4532,7 +4532,7 @@ int clr_history(int histype)
if (hislen != 0 && histype >= 0 && histype < HIST_COUNT) {
hisptr = history[histype];
for (i = hislen; i--; ) {
- free(hisptr->hisstr);
+ xfree(hisptr->hisstr);
clear_hist_entry(hisptr);
}
hisidx[histype] = -1; /* mark history as cleared */
@@ -4571,7 +4571,7 @@ int del_history_entry(int histype, char_u *str)
break;
if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) {
found = TRUE;
- free(hisptr->hisstr);
+ xfree(hisptr->hisstr);
clear_hist_entry(hisptr);
} else {
if (i != last) {
@@ -4603,7 +4603,7 @@ int del_history_idx(int histype, int idx)
if (i < 0)
return FALSE;
idx = hisidx[histype];
- free(history[histype][i].hisstr);
+ xfree(history[histype][i].hisstr);
/* When deleting the last added search string in a mapping, reset
* last_maptick, so that the last added search string isn't deleted again.
@@ -4837,7 +4837,7 @@ int read_viminfo_history(vir_T *virp, int writing)
viminfo_history[type][viminfo_hisidx[type]++] = p;
}
}
- free(val);
+ xfree(val);
}
return viminfo_readline(virp);
}
@@ -4875,7 +4875,7 @@ void finish_viminfo_history(void)
idx = hislen - 1;
}
for (i = 0; i < viminfo_hisidx[type]; i++) {
- free(history[type][idx].hisstr);
+ xfree(history[type][idx].hisstr);
history[type][idx].hisstr = viminfo_history[type][i];
history[type][idx].viminfo = TRUE;
if (--idx < 0)
@@ -4887,7 +4887,7 @@ void finish_viminfo_history(void)
history[type][idx++].hisnum = ++hisnum[type];
idx %= hislen;
}
- free(viminfo_history[type]);
+ xfree(viminfo_history[type]);
viminfo_history[type] = NULL;
viminfo_hisidx[type] = 0;
}
@@ -4974,8 +4974,8 @@ void write_viminfo_history(FILE *fp, int merge)
}
for (i = 0; i < viminfo_hisidx[type]; ++i)
if (viminfo_history[type] != NULL)
- free(viminfo_history[type][i]);
- free(viminfo_history[type]);
+ xfree(viminfo_history[type][i]);
+ xfree(viminfo_history[type]);
viminfo_history[type] = NULL;
viminfo_hisidx[type] = 0;
}
@@ -5161,7 +5161,7 @@ static int ex_window(void)
if (aborting() && cmdwin_result != K_IGNORE)
cmdwin_result = Ctrl_C;
/* Set the new command line from the cmdline buffer. */
- free(ccline.cmdbuff);
+ xfree(ccline.cmdbuff);
if (cmdwin_result == K_XF1 || cmdwin_result == K_XF2) { /* :qa[!] typed */
char *p = (cmdwin_result == K_XF2) ? "qa" : "qa!";
@@ -5257,13 +5257,13 @@ char_u *script_get(exarg_T *eap, char_u *cmd)
NUL, eap->cookie, 0);
if (theline == NULL || STRCMP(end_pattern, theline) == 0) {
- free(theline);
+ xfree(theline);
break;
}
ga_concat(&ga, theline);
ga_append(&ga, '\n');
- free(theline);
+ xfree(theline);
}
ga_append(&ga, NUL);
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 9267e7991c..42779d6b71 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -496,19 +496,19 @@ vim_findfile_init (
}
if (temp == NULL || wc_path == NULL) {
- free(buf);
- free(temp);
- free(wc_path);
+ xfree(buf);
+ xfree(temp);
+ xfree(wc_path);
goto error_return;
}
STRCPY(temp, search_ctx->ffsc_fix_path + len);
STRCAT(temp, search_ctx->ffsc_wc_path);
- free(search_ctx->ffsc_wc_path);
- free(wc_path);
+ xfree(search_ctx->ffsc_wc_path);
+ xfree(wc_path);
search_ctx->ffsc_wc_path = temp;
}
- free(buf);
+ xfree(buf);
}
sptr = ff_create_stack_element(ff_expand_buffer,
@@ -563,7 +563,7 @@ void vim_findfile_cleanup(void *ctx)
vim_findfile_free_visited(ctx);
ff_clear(ctx);
- free(ctx);
+ xfree(ctx);
}
/*
@@ -947,7 +947,7 @@ char_u *vim_findfile(void *search_ctx_arg)
break;
}
- free(file_path);
+ xfree(file_path);
return NULL;
}
@@ -975,8 +975,8 @@ static void vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp)
vp = (*list_headp)->ffvl_next;
ff_free_visited_list((*list_headp)->ffvl_visited_list);
- free((*list_headp)->ffvl_filename);
- free(*list_headp);
+ xfree((*list_headp)->ffvl_filename);
+ xfree(*list_headp);
*list_headp = vp;
}
*list_headp = NULL;
@@ -988,8 +988,8 @@ static void ff_free_visited_list(ff_visited_T *vl)
while (vl != NULL) {
vp = vl->ffv_next;
- free(vl->ffv_wc_path);
- free(vl);
+ xfree(vl->ffv_wc_path);
+ xfree(vl);
vl = vp;
}
vl = NULL;
@@ -1205,13 +1205,13 @@ static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx)
static void ff_free_stack_element(ff_stack_T *stack_ptr)
{
/* free handles possible NULL pointers */
- free(stack_ptr->ffs_fix_path);
- free(stack_ptr->ffs_wc_path);
+ xfree(stack_ptr->ffs_fix_path);
+ xfree(stack_ptr->ffs_wc_path);
if (stack_ptr->ffs_filearray != NULL)
FreeWild(stack_ptr->ffs_filearray_size, stack_ptr->ffs_filearray);
- free(stack_ptr);
+ xfree(stack_ptr);
}
/*
@@ -1225,19 +1225,19 @@ static void ff_clear(ff_search_ctx_T *search_ctx)
while ((sptr = ff_pop(search_ctx)) != NULL)
ff_free_stack_element(sptr);
- free(search_ctx->ffsc_file_to_search);
- free(search_ctx->ffsc_start_dir);
- free(search_ctx->ffsc_fix_path);
- free(search_ctx->ffsc_wc_path);
+ xfree(search_ctx->ffsc_file_to_search);
+ xfree(search_ctx->ffsc_start_dir);
+ xfree(search_ctx->ffsc_fix_path);
+ xfree(search_ctx->ffsc_wc_path);
if (search_ctx->ffsc_stopdirs_v != NULL) {
int i = 0;
while (search_ctx->ffsc_stopdirs_v[i] != NULL) {
- free(search_ctx->ffsc_stopdirs_v[i]);
+ xfree(search_ctx->ffsc_stopdirs_v[i]);
i++;
}
- free(search_ctx->ffsc_stopdirs_v);
+ xfree(search_ctx->ffsc_stopdirs_v);
}
search_ctx->ffsc_stopdirs_v = NULL;
@@ -1327,9 +1327,9 @@ static void *fdip_search_ctx = NULL;
#if defined(EXITFREE)
void free_findfile(void)
{
- free(ff_file_to_find);
+ xfree(ff_file_to_find);
vim_findfile_cleanup(fdip_search_ctx);
- free(ff_expand_buffer);
+ xfree(ff_expand_buffer);
}
#endif
@@ -1382,7 +1382,7 @@ find_file_in_path_option (
expand_env(ptr, NameBuff, MAXPATHL);
ptr[len] = save_char;
- free(ff_file_to_find);
+ xfree(ff_file_to_find);
ff_file_to_find = vim_strsave(NameBuff);
}
@@ -1487,7 +1487,7 @@ find_file_in_path_option (
fdip_search_ctx, FALSE, rel_fname);
if (fdip_search_ctx != NULL)
did_findfile_init = TRUE;
- free(buf);
+ xfree(buf);
}
}
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 233a7d4aac..def1cc1d1a 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -881,12 +881,12 @@ retry:
notconverted = TRUE;
conv_error = 0;
if (fenc_alloced)
- free(fenc);
+ xfree(fenc);
fenc = (char_u *)"";
fenc_alloced = FALSE;
} else {
if (fenc_alloced)
- free(fenc);
+ xfree(fenc);
if (fenc_next != NULL) {
fenc = next_fenc(&fenc_next);
fenc_alloced = (fenc_next != NULL);
@@ -897,7 +897,7 @@ retry:
}
if (tmpname != NULL) {
os_remove((char *)tmpname); // delete converted file
- free(tmpname);
+ xfree(tmpname);
tmpname = NULL;
}
}
@@ -1026,7 +1026,7 @@ retry:
}
if (linerest) /* copy characters from the previous buffer */
memmove(new_buffer, ptr - linerest, (size_t)linerest);
- free(buffer);
+ xfree(buffer);
buffer = new_buffer;
ptr = buffer + linerest;
line_start = buffer;
@@ -1215,7 +1215,7 @@ retry:
} else {
/* BOM detected: set "fenc" and jump back */
if (fenc_alloced)
- free(fenc);
+ xfree(fenc);
fenc = ccname;
fenc_alloced = FALSE;
}
@@ -1738,7 +1738,7 @@ failed:
OPT_FREE | OPT_LOCAL, 0);
}
if (fenc_alloced)
- free(fenc);
+ xfree(fenc);
# ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1) {
iconv_close(iconv_fd);
@@ -1757,7 +1757,7 @@ failed:
fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
}
#endif
- free(buffer);
+ xfree(buffer);
#ifdef HAVE_DUP
if (read_stdin) {
@@ -1769,7 +1769,7 @@ failed:
if (tmpname != NULL) {
os_remove((char *)tmpname); // delete converted file
- free(tmpname);
+ xfree(tmpname);
}
--no_wait_return; /* may wait for return now */
@@ -1886,7 +1886,7 @@ failed:
c = TRUE;
msg_add_lines(c, (long)linecnt, filesize);
- free(keep_msg);
+ xfree(keep_msg);
keep_msg = NULL;
msg_scrolled_ign = TRUE;
p = msg_trunc_attr(IObuff, FALSE, 0);
@@ -2084,7 +2084,7 @@ void set_forced_fenc(exarg_T *eap)
if (eap->force_enc != 0) {
char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
set_string_option_direct((char_u *)"fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
- free(fenc);
+ xfree(fenc);
}
}
@@ -2113,7 +2113,7 @@ static char_u *next_fenc(char_u **pp)
r = vim_strnsave(*pp, (int)(p - *pp));
*pp = p + 1;
p = enc_canonize(r);
- free(r);
+ xfree(r);
r = p;
}
return r;
@@ -2157,7 +2157,7 @@ readfile_charconvert (
MSG(errmsg);
if (tmpname != NULL) {
os_remove((char *)tmpname); // delete converted file
- free(tmpname);
+ xfree(tmpname);
tmpname = NULL;
}
}
@@ -2816,7 +2816,7 @@ buf_write (
*/
backup = modname(rootname, backup_ext, FALSE);
if (backup == NULL) {
- free(rootname);
+ xfree(rootname);
some_error = TRUE; /* out of memory */
goto nobackup;
}
@@ -2832,7 +2832,7 @@ buf_write (
* link). If we don't check here, we either ruin the file when
* copying or erase it after writing.
*/
- free(backup);
+ xfree(backup);
backup = NULL; /* no backup file to delete */
} else if (!p_bk) {
/*
@@ -2851,13 +2851,13 @@ buf_write (
}
/* They all exist??? Must be something wrong. */
if (*wp == 'a') {
- free(backup);
+ xfree(backup);
backup = NULL;
}
}
}
}
- free(rootname);
+ xfree(rootname);
/*
* Try to create the backup file
@@ -2871,7 +2871,7 @@ buf_write (
O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW,
perm & 0777);
if (bfd < 0) {
- free(backup);
+ xfree(backup);
backup = NULL;
} else {
/* set file protection same as original file, but
@@ -2939,7 +2939,7 @@ buf_write (
}
nobackup:
close(fd); /* ignore errors for closing read file */
- free(copybuf);
+ xfree(copybuf);
if (backup == NULL && errmsg == NULL)
errmsg = (char_u *)_(
@@ -2986,7 +2986,7 @@ nobackup:
backup = NULL;
else {
backup = modname(rootname, backup_ext, FALSE);
- free(rootname);
+ xfree(rootname);
}
if (backup != NULL) {
@@ -3004,7 +3004,7 @@ nobackup:
--*p;
/* They all exist??? Must be something wrong! */
if (*p == 'a') {
- free(backup);
+ xfree(backup);
backup = NULL;
}
}
@@ -3023,7 +3023,7 @@ nobackup:
if (vim_rename(fname, backup) == 0)
break;
- free(backup); /* don't do the rename below */
+ xfree(backup); /* don't do the rename below */
backup = NULL;
}
}
@@ -3250,7 +3250,7 @@ restore_backup:
}
if (wfname != fname)
- free(wfname);
+ xfree(wfname);
goto fail;
}
errmsg = NULL;
@@ -3446,7 +3446,7 @@ restore_backup:
}
}
os_remove((char *)wfname);
- free(wfname);
+ xfree(wfname);
}
if (end == 0) {
@@ -3606,7 +3606,7 @@ restore_backup:
EMSG(_("E205: Patchmode: can't save original file"));
else if (!os_file_exists((char_u *)org)) {
vim_rename(backup, (char_u *)org);
- free(backup); /* don't delete the file */
+ xfree(backup); /* don't delete the file */
backup = NULL;
#ifdef UNIX
set_file_time((char_u *)org,
@@ -3632,7 +3632,7 @@ restore_backup:
}
if (org != NULL) {
os_setperm((char_u *)org, os_getperm(fname) & 0777);
- free(org);
+ xfree(org);
}
}
@@ -3655,11 +3655,11 @@ nofail:
/* Done saving, we accept changed buffer warnings again */
buf->b_saving = false;
- free(backup);
+ xfree(backup);
if (buffer != smallbuf)
- free(buffer);
- free(fenc_tofree);
- free(write_info.bw_conv_buf);
+ xfree(buffer);
+ xfree(fenc_tofree);
+ xfree(write_info.bw_conv_buf);
# ifdef USE_ICONV
if (write_info.bw_iconv_fd != (iconv_t)-1) {
iconv_close(write_info.bw_iconv_fd);
@@ -3692,7 +3692,7 @@ nofail:
STRCAT(IObuff, errmsg);
emsg(IObuff);
if (errmsg_allocated)
- free(errmsg);
+ xfree(errmsg);
retval = FAIL;
if (end == 0) {
@@ -4314,7 +4314,7 @@ void shorten_fnames(int force)
&& (force
|| buf->b_sfname == NULL
|| path_is_absolute_path(buf->b_sfname))) {
- free(buf->b_sfname);
+ xfree(buf->b_sfname);
buf->b_sfname = NULL;
p = path_shorten_fname(buf->b_ffname, dirname);
if (p != NULL) {
@@ -4366,7 +4366,7 @@ modname (
retval = xmalloc(MAXPATHL + extlen + 3);
if (os_dirname(retval, MAXPATHL) == FAIL ||
(fnamelen = (int)STRLEN(retval)) == 0) {
- free(retval);
+ xfree(retval);
return NULL;
}
if (!after_pathsep(retval, retval + fnamelen)) {
@@ -4596,7 +4596,7 @@ int vim_rename(char_u *from, char_u *to)
break;
}
- free(buffer);
+ xfree(buffer);
close(fd_in);
if (close(fd_out) < 0)
errmsg = _("E209: Error closing \"%s\"");
@@ -4705,11 +4705,11 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum) {
p = vim_strsave(ml_get_buf(frombuf, lnum, FALSE));
if (ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
- free(p);
+ xfree(p);
retval = FAIL;
break;
}
- free(p);
+ xfree(p);
}
/* Delete all the lines in "frombuf". */
@@ -4922,8 +4922,8 @@ buf_check_timestamp (
already_warned = TRUE;
}
- free(path);
- free(tbuf);
+ xfree(path);
+ xfree(tbuf);
}
if (reload) {
@@ -5041,7 +5041,7 @@ void buf_reload(buf_T *buf, int orig_mode)
}
}
}
- free(ea.cmd);
+ xfree(ea.cmd);
if (savebuf != NULL && buf_valid(savebuf))
wipe_buffer(savebuf, FALSE);
@@ -5315,7 +5315,7 @@ static void show_autocmd(AutoPat *ap, event_T event)
*/
static void au_remove_pat(AutoPat *ap)
{
- free(ap->pat);
+ xfree(ap->pat);
ap->pat = NULL;
ap->buflocal_nr = -1;
au_need_clean = TRUE;
@@ -5329,7 +5329,7 @@ static void au_remove_cmds(AutoPat *ap)
AutoCmd *ac;
for (ac = ap->cmds; ac != NULL; ac = ac->next) {
- free(ac->cmd);
+ xfree(ac->cmd);
ac->cmd = NULL;
}
au_need_clean = TRUE;
@@ -5361,8 +5361,8 @@ static void au_cleanup(void)
* the command has been marked for deletion */
if (ap->pat == NULL || ac->cmd == NULL) {
*prev_ac = ac->next;
- free(ac->cmd);
- free(ac);
+ xfree(ac->cmd);
+ xfree(ac);
} else
prev_ac = &(ac->next);
}
@@ -5371,7 +5371,7 @@ static void au_cleanup(void)
if (ap->pat == NULL) {
*prev_ap = ap->next;
vim_regfree(ap->reg_prog);
- free(ap);
+ xfree(ap);
} else
prev_ap = &(ap->next);
}
@@ -5445,7 +5445,7 @@ static void au_del_group(char_u *name)
if (i == AUGROUP_ERROR) /* the group doesn't exist */
EMSG2(_("E367: No such group: \"%s\""), name);
else {
- free(AUGROUP_NAME(i));
+ xfree(AUGROUP_NAME(i));
AUGROUP_NAME(i) = NULL;
}
}
@@ -5637,7 +5637,7 @@ char_u *au_event_disable(char *what)
else
STRCAT(new_ei, what);
set_string_option_direct((char_u *)"ei", -1, new_ei, OPT_FREE, SID_NONE);
- free(new_ei);
+ xfree(new_ei);
return save_ei;
}
@@ -5647,7 +5647,7 @@ void au_event_restore(char_u *old_ei)
if (old_ei != NULL) {
set_string_option_direct((char_u *)"ei", -1, old_ei,
OPT_FREE, SID_NONE);
- free(old_ei);
+ xfree(old_ei);
}
}
@@ -5782,8 +5782,8 @@ void do_autocmd(char_u *arg, int forceit)
}
if (need_free)
- free(cmd);
- free(envpat);
+ xfree(cmd);
+ xfree(envpat);
}
/*
@@ -5807,7 +5807,7 @@ static int au_get_grouparg(char_u **argp)
group = AUGROUP_ALL; /* no match, use all groups */
else
*argp = skipwhite(p); /* match, skip over group name */
- free(group_name);
+ xfree(group_name);
}
return group;
}
@@ -5984,10 +5984,10 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
&ap->allow_dirs, TRUE);
if (reg_pat != NULL)
ap->reg_prog = vim_regcomp(reg_pat, RE_MAGIC);
- free(reg_pat);
+ xfree(reg_pat);
if (reg_pat == NULL || ap->reg_prog == NULL) {
- free(ap->pat);
- free(ap);
+ xfree(ap->pat);
+ xfree(ap);
return FAIL;
}
}
@@ -6186,7 +6186,7 @@ aucmd_prepbuf (
/* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
* win_enter_ext(). */
- free(aucmd_win->w_localdir);
+ xfree(aucmd_win->w_localdir);
aucmd_win->w_localdir = NULL;
aco->globaldir = globaldir;
globaldir = NULL;
@@ -6262,7 +6262,7 @@ win_found:
hash_init(&aucmd_win->w_vars->dv_hashtab); /* re-use the hashtab */
curbuf = curwin->w_buffer;
- free(globaldir);
+ xfree(globaldir);
globaldir = aco->globaldir;
/* the buffer contents may have changed */
@@ -6599,7 +6599,7 @@ apply_autocmds_group (
fname = FullName_save(fname, FALSE);
}
if (fname == NULL) { /* out of memory */
- free(sfname);
+ xfree(sfname);
retval = FALSE;
goto BYPASS_AU;
}
@@ -6705,10 +6705,10 @@ apply_autocmds_group (
autocmd_busy = save_autocmd_busy;
filechangeshell_busy = FALSE;
autocmd_nested = save_autocmd_nested;
- free(sourcing_name);
+ xfree(sourcing_name);
sourcing_name = save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
- free(autocmd_fname);
+ xfree(autocmd_fname);
autocmd_fname = save_autocmd_fname;
autocmd_fname_full = save_autocmd_fname_full;
autocmd_bufnr = save_autocmd_bufnr;
@@ -6717,8 +6717,8 @@ apply_autocmds_group (
restore_funccal(save_funccalp);
if (do_profiling == PROF_YES)
prof_child_exit(&wait_time);
- free(fname);
- free(sfname);
+ xfree(fname);
+ xfree(sfname);
--nesting; /* see matching increment above */
// When stopping to execute autocommands, restore the search patterns and
@@ -6730,12 +6730,12 @@ apply_autocmds_group (
did_filetype = FALSE;
while (au_pending_free_buf != NULL) {
buf_T *b = au_pending_free_buf->b_next;
- free(au_pending_free_buf);
+ xfree(au_pending_free_buf);
au_pending_free_buf = b;
}
while (au_pending_free_win != NULL) {
win_T *w = au_pending_free_win->w_next;
- free(au_pending_free_win);
+ xfree(au_pending_free_win);
au_pending_free_win = w;
}
}
@@ -6806,7 +6806,7 @@ auto_next_pat (
char_u *name;
char *s;
- free(sourcing_name);
+ xfree(sourcing_name);
sourcing_name = NULL;
for (ap = apc->curpat; ap != NULL && !got_int; ap = ap->next) {
@@ -6942,9 +6942,9 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
break;
}
- free(fname);
+ xfree(fname);
#ifdef BACKSLASH_IN_FILENAME
- free(sfname);
+ xfree(sfname);
#endif
return retval;
@@ -7124,7 +7124,7 @@ int au_exists(char_u *arg)
}
theend:
- free(arg_save);
+ xfree(arg_save);
return retval;
}
@@ -7203,7 +7203,7 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname)
break;
match = match_file_pat(regpat, NULL, ffname, sfname,
tail, (int)allow_dirs);
- free(regpat);
+ xfree(regpat);
if (match)
return TRUE;
}
@@ -7399,7 +7399,7 @@ file_pat_to_reg_pat (
EMSG(_("E219: Missing {."));
else
EMSG(_("E220: Missing }."));
- free(reg_pat);
+ xfree(reg_pat);
reg_pat = NULL;
}
return reg_pat;
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 281e5b5768..8e6c2a598e 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1326,7 +1326,7 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
sizeof(fold_T) * (size_t)(gap->ga_len - (idx + 1)));
/* move the contained folds one level up */
memmove(fp, nfp, sizeof(fold_T) * (size_t)moved);
- free(nfp);
+ xfree(nfp);
gap->ga_len += moved - 1;
}
}
@@ -1760,7 +1760,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
}
if (*p != NUL) {
p = transstr(text);
- free(text);
+ xfree(text);
text = p;
}
}
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index 31a79db209..953eb58841 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -24,7 +24,7 @@
/// Clear an allocated growing array.
void ga_clear(garray_T *gap)
{
- free(gap->ga_data);
+ xfree(gap->ga_data);
// Initialize growing array without resetting itemsize or growsize
gap->ga_data = NULL;
@@ -114,7 +114,7 @@ void ga_remove_duplicate_strings(garray_T *gap)
// loop over the growing array in reverse
for (int i = gap->ga_len - 1; i > 0; i--) {
if (fnamecmp(fnames[i - 1], fnames[i]) == 0) {
- free(fnames[i]);
+ xfree(fnames[i]);
// close the gap (move all strings one slot lower)
for (int j = i + 1; j < gap->ga_len; j++) {
diff --git a/src/nvim/garray.h b/src/nvim/garray.h
index b758fce5da..642eaf54f0 100644
--- a/src/nvim/garray.h
+++ b/src/nvim/garray.h
@@ -61,7 +61,7 @@ static inline void *ga_append_via_ptr(garray_T *gap, size_t item_size)
ga_clear(_gap); \
} while (false)
-#define FREE_PTR_PTR(ptr) free(*(ptr))
+#define FREE_PTR_PTR(ptr) xfree(*(ptr))
/// Call `free` for every pointer stored in the garray and then frees the
/// garray.
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index d901e99a2d..f45ee609bd 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -167,7 +167,7 @@ void free_buff(buffheader_T *buf)
for (p = buf->bh_first.b_next; p != NULL; p = np) {
np = p->b_next;
- free(p);
+ xfree(p);
}
buf->bh_first.b_next = NULL;
}
@@ -365,7 +365,7 @@ static int read_readbuf(buffheader_T *buf, int advance)
if (advance) {
if (curr->b_str[++buf->bh_index] == NUL) {
buf->bh_first.b_next = curr->b_next;
- free(curr);
+ xfree(curr);
buf->bh_index = 0;
}
}
@@ -495,7 +495,7 @@ void saveRedobuff(void)
s = get_buffcont(&save_redobuff, FALSE);
if (s != NULL) {
add_buff(&redobuff, s, -1L);
- free(s);
+ xfree(s);
}
}
}
@@ -904,7 +904,7 @@ int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, int silent)
typebuf.tb_buf + typebuf.tb_off + offset,
(size_t)(typebuf.tb_len - offset + 1));
if (typebuf.tb_buf != typebuf_init)
- free(typebuf.tb_buf);
+ xfree(typebuf.tb_buf);
typebuf.tb_buf = s1;
memmove(s2 + newoff, typebuf.tb_noremap + typebuf.tb_off,
@@ -913,7 +913,7 @@ int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, int silent)
typebuf.tb_noremap + typebuf.tb_off + offset,
(size_t)(typebuf.tb_len - offset));
if (typebuf.tb_noremap != noremapbuf_init)
- free(typebuf.tb_noremap);
+ xfree(typebuf.tb_noremap);
typebuf.tb_noremap = s2;
typebuf.tb_off = newoff;
@@ -1162,11 +1162,11 @@ void free_typebuf(void)
if (typebuf.tb_buf == typebuf_init)
EMSG2(_(e_intern2), "Free typebuf 1");
else
- free(typebuf.tb_buf);
+ xfree(typebuf.tb_buf);
if (typebuf.tb_noremap == noremapbuf_init)
EMSG2(_(e_intern2), "Free typebuf 2");
else
- free(typebuf.tb_noremap);
+ xfree(typebuf.tb_noremap);
}
/*
@@ -2068,10 +2068,10 @@ static int vgetorpeek(int advance)
i = ins_typebuf(s, noremap,
0, TRUE, cmd_silent || save_m_silent);
if (save_m_expr)
- free(s);
+ xfree(s);
}
- free(save_m_keys);
- free(save_m_str);
+ xfree(save_m_keys);
+ xfree(save_m_str);
if (i == FAIL) {
c = -1;
break;
@@ -2906,9 +2906,9 @@ do_map (
} else { /* new rhs for existing entry */
mp->m_mode &= ~mode; /* remove mode bits */
if (mp->m_mode == 0 && !did_it) { /* reuse entry */
- free(mp->m_str);
+ xfree(mp->m_str);
mp->m_str = vim_strsave(rhs);
- free(mp->m_orig_str);
+ xfree(mp->m_orig_str);
mp->m_orig_str = vim_strsave(orig_rhs);
mp->m_noremap = noremap;
mp->m_nowait = nowait;
@@ -2998,8 +2998,8 @@ do_map (
}
theend:
- free(keys_buf);
- free(arg_buf);
+ xfree(keys_buf);
+ xfree(arg_buf);
return retval;
}
@@ -3012,11 +3012,11 @@ static void map_free(mapblock_T **mpp)
mapblock_T *mp;
mp = *mpp;
- free(mp->m_keys);
- free(mp->m_str);
- free(mp->m_orig_str);
+ xfree(mp->m_keys);
+ xfree(mp->m_str);
+ xfree(mp->m_orig_str);
*mpp = mp->m_next;
- free(mp);
+ xfree(mp);
}
/*
@@ -3211,7 +3211,7 @@ showmap (
if (mapchars != NULL) {
msg_puts(mapchars);
len = (int)STRLEN(mapchars);
- free(mapchars);
+ xfree(mapchars);
}
while (++len <= 3)
@@ -3246,7 +3246,7 @@ showmap (
char_u *s = vim_strsave(mp->m_str);
vim_unescape_csi(s);
msg_outtrans_special(s, FALSE);
- free(s);
+ xfree(s);
}
if (p_verbose > 0)
last_set_msg(mp->m_script_ID);
@@ -3285,7 +3285,7 @@ int map_to_exists(char_u *str, char_u *modechars, int abbr)
mode |= CMDLINE;
retval = map_to_exists_mode(rhs, mode, abbr);
- free(buf);
+ xfree(buf);
return retval;
}
@@ -3469,7 +3469,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
p = NULL;
}
}
- free(p);
+ xfree(p);
}
} /* for (mp) */
} /* for (hash) */
@@ -3499,7 +3499,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
if (STRCMP(*ptr1, *ptr2))
*++ptr1 = *ptr2++;
else {
- free(*ptr2++);
+ xfree(*ptr2++);
count--;
}
}
@@ -3617,7 +3617,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
&& qlen == len
&& !STRNCMP(q, ptr, (size_t)len);
if (q != mp->m_keys) {
- free(q);
+ xfree(q);
}
if (match) {
break;
@@ -3669,7 +3669,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
/* no abbrev. for these chars */
typebuf.tb_no_abbr_cnt += (int)STRLEN(s) + j + 1;
if (mp->m_expr)
- free(s);
+ xfree(s);
}
tb[0] = Ctrl_H;
@@ -3725,13 +3725,13 @@ eval_map_expr (
msg_row = save_msg_row;
restore_cmdline_alloc(save_cmd);
- free(expr);
+ xfree(expr);
if (p == NULL)
return NULL;
/* Escape CSI in the result to be able to use the string as typeahead. */
res = vim_strsave_escape_csi(p);
- free(p);
+ xfree(p);
return res;
}
@@ -4171,7 +4171,7 @@ void add_map(char_u *map, int mode)
p_cpo = (char_u *)""; /* Allow <> notation */
s = vim_strsave(map);
(void)do_map(0, s, mode, FALSE);
- free(s);
+ xfree(s);
p_cpo = cpo_save;
}
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index b5e7ec414c..6e9ad02b3a 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -551,7 +551,7 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum)
p += l;
}
- free(tbuf);
+ xfree(tbuf);
if (psettings->do_syntax)
/* Set colors for next character. */
@@ -1539,7 +1539,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name,
resource->filename)
&& resource->filename[0] != NUL);
- free(buffer);
+ xfree(buffer);
return retval;
}
@@ -1921,7 +1921,7 @@ void mch_print_cleanup(void)
*/
for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) {
if (prt_ps_mb_font.ps_fontname[i] != NULL)
- free(prt_ps_mb_font.ps_fontname[i]);
+ xfree(prt_ps_mb_font.ps_fontname[i]);
prt_ps_mb_font.ps_fontname[i] = NULL;
}
}
@@ -1936,7 +1936,7 @@ void mch_print_cleanup(void)
prt_file_error = FALSE;
}
if (prt_ps_file_name != NULL) {
- free(prt_ps_file_name);
+ xfree(prt_ps_file_name);
prt_ps_file_name = NULL;
}
}
@@ -2342,7 +2342,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
p = expand_env_save(psettings->outfile);
if (p != NULL) {
prt_ps_fd = mch_fopen((char *)p, WRITEBIN);
- free(p);
+ xfree(p);
}
}
if (prt_ps_fd == NULL) {
@@ -3032,7 +3032,7 @@ int mch_print_text_out(char_u *p, size_t len)
/* Need to free any translated characters */
if (prt_do_conv)
- free(p);
+ xfree(p);
prt_text_run += char_width;
prt_pos_x += char_width;
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 6b90c4fee4..2da937633e 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -53,7 +53,7 @@ void hash_init(hashtab_T *ht)
void hash_clear(hashtab_T *ht)
{
if (ht->ht_array != ht->ht_smallarray) {
- free(ht->ht_array);
+ xfree(ht->ht_array);
}
}
@@ -65,7 +65,7 @@ void hash_clear_all(hashtab_T *ht, unsigned int off)
size_t todo = ht->ht_used;
for (hashitem_T *hi = ht->ht_array; todo > 0; ++hi) {
if (!HASHITEM_EMPTY(hi)) {
- free(hi->hi_key - off);
+ xfree(hi->hi_key - off);
todo--;
}
}
@@ -351,7 +351,7 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
}
if (ht->ht_array != ht->ht_smallarray) {
- free(ht->ht_array);
+ xfree(ht->ht_array);
}
ht->ht_array = newarray;
ht->ht_mask = newmask;
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index bd9e005676..48d8522865 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -433,7 +433,7 @@ static void cs_stat_emsg(char *fname)
(void)sprintf(buf, stat_emsg, fname, errno);
(void)EMSG(buf);
- free(buf);
+ xfree(buf);
}
@@ -470,7 +470,7 @@ cs_add_common (
if (fname == NULL)
goto add_err;
fname = (char *)vim_strnsave((char_u *)fname, len);
- free(fbuf);
+ xfree(fbuf);
FileInfo file_info;
bool file_info_ok = os_fileinfo(fname, &file_info);
if (!file_info_ok) {
@@ -538,15 +538,15 @@ staterr:
}
}
- free(fname);
- free(fname2);
- free(ppath);
+ xfree(fname);
+ xfree(fname2);
+ xfree(ppath);
return CSCOPE_SUCCESS;
add_err:
- free(fname2);
- free(fname);
- free(ppath);
+ xfree(fname2);
+ xfree(fname);
+ xfree(ppath);
return CSCOPE_FAILURE;
} /* cs_add_common */
@@ -605,7 +605,7 @@ static int cs_cnt_matches(int idx)
cs_reading_emsg(idx);
- free(buf);
+ xfree(buf);
return -1;
}
@@ -636,7 +636,7 @@ static int cs_cnt_matches(int idx)
break;
}
- free(buf);
+ xfree(buf);
return nlines;
} /* cs_cnt_matches */
@@ -805,9 +805,9 @@ err_closing:
}
# ifdef UNIX
/* on Win32 we still need prog */
- free(prog);
+ xfree(prog);
# endif
- free(ppath);
+ xfree(ppath);
#if defined(UNIX)
# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
@@ -852,8 +852,8 @@ err_closing:
si.hStdInput = stdin_rd;
created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE,
NULL, NULL, &si, &pi);
- free(prog);
- free(cmd);
+ xfree(prog);
+ xfree(cmd);
if (!created) {
PERROR(_("cs_create_connection exec failed"));
@@ -982,7 +982,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
sprintf(buf, nf, *qfpos, *(qfpos-1));
(void)EMSG(buf);
- free(buf);
+ xfree(buf);
return FALSE;
}
@@ -1022,22 +1022,22 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
if (nummatches[i] == 0)
(void)cs_read_prompt(i);
}
- free(cmd);
+ xfree(cmd);
if (totmatches == 0) {
char *nf = _("E259: no matches found for cscope query %s of %s");
char *buf;
if (!verbose) {
- free(nummatches);
+ xfree(nummatches);
return FALSE;
}
buf = xmalloc(strlen(opt) + strlen(pat) + strlen(nf));
sprintf(buf, nf, opt, pat);
(void)EMSG(buf);
- free(buf);
- free(nummatches);
+ xfree(buf);
+ xfree(nummatches);
return FALSE;
}
@@ -1079,8 +1079,8 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
}
}
os_remove((char *)tmp);
- free(tmp);
- free(nummatches);
+ xfree(tmp);
+ xfree(nummatches);
return TRUE;
} else {
char **matches = NULL, **contexts = NULL;
@@ -1089,7 +1089,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
/* read output */
cs_fill_results((char *)pat, totmatches, nummatches, &matches,
&contexts, &matched);
- free(nummatches);
+ xfree(nummatches);
if (matches == NULL)
return FALSE;
@@ -1424,12 +1424,12 @@ static char *cs_manage_matches(char **matches, char **contexts, int totmatches,
if (mp != NULL) {
if (cnt > 0)
while (cnt--) {
- free(mp[cnt]);
+ xfree(mp[cnt]);
if (cp != NULL)
- free(cp[cnt]);
+ xfree(cp[cnt]);
}
- free(mp);
- free(cp);
+ xfree(mp);
+ xfree(cp);
}
mp = NULL;
cp = NULL;
@@ -1537,14 +1537,14 @@ static void cs_file_results(FILE *f, int *nummatches_a)
else
fprintf(f, "%s\t%s\t%s %s\n", fullname, slno, context, search);
- free(context);
- free(fullname);
+ xfree(context);
+ xfree(fullname);
} /* for all matches */
(void)cs_read_prompt(i);
} /* for all cscope connections */
- free(buf);
+ xfree(buf);
}
/*
@@ -1583,7 +1583,7 @@ static void cs_fill_results(char *tagstr, int totmatches, int *nummatches_a, cha
matches[totsofar] = cs_make_vim_style_matches(fullname, slno, search,
tagstr);
- free(fullname);
+ xfree(fullname);
if (strcmp(cntx, "<global>") == 0)
cntxts[totsofar] = NULL;
@@ -1601,16 +1601,16 @@ static void cs_fill_results(char *tagstr, int totmatches, int *nummatches_a, cha
if (totsofar == 0) {
/* No matches, free the arrays and return NULL in "*matches_p". */
- free(matches);
+ xfree(matches);
matches = NULL;
- free(cntxts);
+ xfree(cntxts);
cntxts = NULL;
}
*matched = totsofar;
*matches_p = matches;
*cntxts_p = cntxts;
- free(buf);
+ xfree(buf);
} /* cs_fill_results */
@@ -1661,7 +1661,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
(void)sprintf(buf, cstag_msg, ptag);
MSG_PUTS_ATTR(buf, hl_attr(HLF_T));
- free(tbuf);
+ xfree(tbuf);
MSG_PUTS_ATTR(_("\n # line"), hl_attr(HLF_T)); /* strlen is 7 */
msg_advance(msg_col + 2);
@@ -1727,7 +1727,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
MSG_PUTS_LONG(extra);
}
- free(tbuf); /* only after printing extra due to strtok use */
+ xfree(tbuf); /* only after printing extra due to strtok use */
if (msg_col)
msg_putchar('\n');
@@ -1741,7 +1741,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
num++;
} /* for all matches */
- free(buf);
+ xfree(buf);
} /* cs_print_tags_priv */
@@ -1806,7 +1806,7 @@ static int cs_read_prompt(int i)
else if (p_csverbose)
cs_reading_emsg(i); /* don't have additional information */
cs_release_csp(i, TRUE);
- free(buf);
+ xfree(buf);
return CSCOPE_FAILURE;
}
@@ -1821,7 +1821,7 @@ static int cs_read_prompt(int i)
break; /* did find the prompt */
}
- free(buf);
+ xfree(buf);
return CSCOPE_SUCCESS;
}
@@ -1947,9 +1947,9 @@ static void cs_release_csp(int i, int freefnpp)
(void)fclose(csinfo[i].to_fp);
if (freefnpp) {
- free(csinfo[i].fname);
- free(csinfo[i].ppath);
- free(csinfo[i].flags);
+ xfree(csinfo[i].fname);
+ xfree(csinfo[i].ppath);
+ xfree(csinfo[i].flags);
}
clear_csinfo(i);
@@ -1996,13 +1996,13 @@ static int cs_reset(exarg_T *eap)
MSG_PUTS_ATTR(buf, hl_attr(HLF_R));
}
}
- free(dblist[i]);
- free(pplist[i]);
- free(fllist[i]);
+ xfree(dblist[i]);
+ xfree(pplist[i]);
+ xfree(fllist[i]);
}
- free(dblist);
- free(pplist);
- free(fllist);
+ xfree(dblist);
+ xfree(pplist);
+ xfree(fllist);
if (p_csverbose)
MSG_ATTR(_("All cscope databases reset"), hl_attr(HLF_R) | MSG_HIST);
@@ -2061,7 +2061,7 @@ static char *cs_resolve_file(int i, char *name)
fullname = xstrdup(name);
}
- free(csdir);
+ xfree(csdir);
return fullname;
}
@@ -2109,7 +2109,7 @@ void cs_end(void)
for (i = 0; i < csinfo_size; i++)
cs_release_csp(i, TRUE);
- free(csinfo);
+ xfree(csinfo);
csinfo_size = 0;
}
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 5711207933..183456d3f7 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -297,7 +297,7 @@ int set_indent(int size, int flags)
}
retval = true;
} else {
- free(newline);
+ xfree(newline);
}
curwin->w_cursor.col = ind_len;
return retval;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 3b9214abc1..c0613331cf 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -136,7 +136,7 @@ bool cin_is_cinword(char_u *line)
}
}
- free(cinw_buf);
+ xfree(cinw_buf);
return retval;
}
@@ -3280,7 +3280,7 @@ theend:
/* put the cursor back where it belongs */
curwin->w_cursor = cur_curpos;
- free(linecopy);
+ xfree(linecopy);
if (amount < 0)
return 0;
diff --git a/src/nvim/lib/khash.h b/src/nvim/lib/khash.h
index c9198e048c..96e7ea6df0 100644
--- a/src/nvim/lib/khash.h
+++ b/src/nvim/lib/khash.h
@@ -181,7 +181,7 @@ typedef khint_t khiter_t;
#define krealloc(P,Z) xrealloc(P,Z)
#endif
#ifndef kfree
-#define kfree(P) free(P)
+#define kfree(P) xfree(P)
#endif
static const double __ac_HASH_UPPER = 0.77;
diff --git a/src/nvim/lib/klist.h b/src/nvim/lib/klist.h
index f8dc7d4c43..7df809f07b 100644
--- a/src/nvim/lib/klist.h
+++ b/src/nvim/lib/klist.h
@@ -44,9 +44,9 @@
static inline void kmp_destroy_##name(kmp_##name##_t *mp) { \
size_t k; \
for (k = 0; k < mp->n; ++k) { \
- kmpfree_f(mp->buf[k]); free(mp->buf[k]); \
+ kmpfree_f(mp->buf[k]); xfree(mp->buf[k]); \
} \
- free(mp->buf); free(mp); \
+ xfree(mp->buf); xfree(mp); \
} \
static inline kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \
++mp->cnt; \
@@ -95,7 +95,7 @@
kmp_free(name, kl->mp, p); \
kmp_free(name, kl->mp, p); \
kmp_destroy(name, kl->mp); \
- free(kl); \
+ xfree(kl); \
} \
static inline kltype_t *kl_pushp_##name(kl_##name##_t *kl) { \
kl1_##name *q, *p = kmp_alloc(name, kl->mp); \
diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h
index 982b5d6f1c..0466cb229c 100644
--- a/src/nvim/lib/kvec.h
+++ b/src/nvim/lib/kvec.h
@@ -55,7 +55,7 @@ int main() {
#define kvec_t(type) struct { size_t size, capacity; type *items; }
#define kv_init(v) ((v).size = (v).capacity = 0, (v).items = 0)
-#define kv_destroy(v) free((v).items)
+#define kv_destroy(v) xfree((v).items)
#define kv_A(v, i) ((v).items[(i)])
#define kv_pop(v) ((v).items[--(v).size])
#define kv_size(v) ((v).size)
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a03fd2e8a9..4753dc31c3 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -644,7 +644,7 @@ main_loop (
// duplicates.
p = keep_msg;
msg_attr(p, keep_msg_attr);
- free(p);
+ xfree(p);
}
if (need_fileinfo) { /* show file info after redraw */
fileinfo(FALSE, TRUE, FALSE);
@@ -840,7 +840,7 @@ static void init_locale(void)
bindtextdomain(VIMPACKAGE, (char *)NameBuff);
}
if (mustfree)
- free(p);
+ xfree(p);
textdomain(VIMPACKAGE);
}
TIME_MSG("locale set");
@@ -1285,7 +1285,7 @@ scripterror:
char_u *r;
r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), TRUE);
- free(p);
+ xfree(p);
p = r;
}
@@ -1322,7 +1322,7 @@ scripterror:
p = xmalloc(STRLEN(parmp->commands[0]) + 3);
sprintf((char *)p, ":%s\r", parmp->commands[0]);
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
- free(p);
+ xfree(p);
}
TIME_MSG("parsing arguments");
}
@@ -1753,7 +1753,7 @@ static void exe_commands(mparm_T *parmp)
for (i = 0; i < parmp->n_commands; ++i) {
do_cmdline_cmd(parmp->commands[i]);
if (parmp->cmds_tofree[i])
- free(parmp->commands[i]);
+ xfree(parmp->commands[i]);
}
sourcing_name = NULL;
current_SID = 0;
diff --git a/src/nvim/map.c b/src/nvim/map.c
index 06ae19f5bc..5d83020619 100644
--- a/src/nvim/map.c
+++ b/src/nvim/map.c
@@ -45,7 +45,7 @@
void map_##T##_##U##_free(Map(T, U) *map) \
{ \
kh_destroy(T##_##U##_map, map->table); \
- free(map); \
+ xfree(map); \
} \
\
U map_##T##_##U##_get(Map(T, U) *map, T key) \
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index bc4eaa5b60..a142d12c13 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -131,7 +131,7 @@ int setmark_pos(int c, pos_T *pos, int fnum)
i = c - 'A';
namedfm[i].fmark.mark = *pos;
namedfm[i].fmark.fnum = fnum;
- free(namedfm[i].fname);
+ xfree(namedfm[i].fname);
namedfm[i].fname = NULL;
return OK;
}
@@ -157,7 +157,7 @@ void setpcmark(void)
/* If jumplist is full: remove oldest entry */
if (++curwin->w_jumplistlen > JUMPLISTSIZE) {
curwin->w_jumplistlen = JUMPLISTSIZE;
- free(curwin->w_jumplist[0].fname);
+ xfree(curwin->w_jumplist[0].fname);
for (i = 1; i < JUMPLISTSIZE; ++i)
curwin->w_jumplist[i - 1] = curwin->w_jumplist[i];
}
@@ -496,7 +496,7 @@ void fmarks_check_names(buf_T *buf)
}
}
- free(name);
+ xfree(name);
}
static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf)
@@ -505,7 +505,7 @@ static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf)
&& fm->fname != NULL
&& fnamecmp(name, fm->fname) == 0) {
fm->fmark.fnum = buf->b_fnum;
- free(fm->fname);
+ xfree(fm->fname);
fm->fname = NULL;
}
}
@@ -623,7 +623,7 @@ void do_marks(exarg_T *eap)
arg, &namedfm[i].fmark.mark, name,
namedfm[i].fmark.fnum == curbuf->b_fnum);
if (namedfm[i].fmark.fnum != 0)
- free(name);
+ xfree(name);
}
}
show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE);
@@ -678,7 +678,7 @@ show_one_mark (
if (name != NULL) {
msg_outtrans_attr(name, current ? hl_attr(HLF_D) : 0);
if (mustfree)
- free(name);
+ xfree(name);
}
}
ui_flush(); /* show one line at a time */
@@ -735,7 +735,7 @@ void ex_delmarks(exarg_T *eap)
else
n = i - 'A';
namedfm[n].fmark.mark.lnum = 0;
- free(namedfm[n].fname);
+ xfree(namedfm[n].fname);
namedfm[n].fname = NULL;
}
}
@@ -777,7 +777,7 @@ void ex_jumps(exarg_T *eap)
msg_putchar('\n');
if (got_int) {
- free(name);
+ xfree(name);
break;
}
sprintf((char *)IObuff, "%c %2d %5ld %4d ",
@@ -790,7 +790,7 @@ void ex_jumps(exarg_T *eap)
msg_outtrans_attr(name,
curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
? hl_attr(HLF_D) : 0);
- free(name);
+ xfree(name);
os_breakcheck();
}
ui_flush();
@@ -824,7 +824,7 @@ void ex_changes(exarg_T *eap)
msg_outtrans(IObuff);
name = mark_line(&curbuf->b_changelist[i], 17);
msg_outtrans_attr(name, hl_attr(HLF_D));
- free(name);
+ xfree(name);
os_breakcheck();
}
ui_flush();
@@ -1120,7 +1120,7 @@ static void cleanup_jumplist(void)
if (i >= curwin->w_jumplistlen) /* no duplicate */
curwin->w_jumplist[to++] = curwin->w_jumplist[from];
else
- free(curwin->w_jumplist[from].fname);
+ xfree(curwin->w_jumplist[from].fname);
}
if (curwin->w_jumplistidx == curwin->w_jumplistlen)
curwin->w_jumplistidx = to;
@@ -1151,7 +1151,7 @@ void free_jumplist(win_T *wp)
int i;
for (i = 0; i < wp->w_jumplistlen; ++i)
- free(wp->w_jumplist[i].fname);
+ xfree(wp->w_jumplist[i].fname);
}
void set_last_cursor(win_T *win)
@@ -1167,7 +1167,7 @@ void free_all_marks(void)
for (i = 0; i < NMARKS + EXTRA_MARKS; i++)
if (namedfm[i].fmark.mark.lnum != 0)
- free(namedfm[i].fname);
+ xfree(namedfm[i].fname);
}
#endif
@@ -1212,7 +1212,7 @@ int read_viminfo_filemark(vir_T *virp, int force)
fm->fmark.mark.coladd = 0;
fm->fmark.fnum = 0;
str = skipwhite(str);
- free(fm->fname);
+ xfree(fm->fname);
fm->fname = viminfo_readstring(virp, (int)(str - virp->vir_line),
FALSE);
}
@@ -1247,9 +1247,9 @@ void write_viminfo_filemarks(FILE *fp)
: (name != NULL
&& STRCMP(name, namedfm[i].fname) == 0)))
break;
- free(name);
+ xfree(name);
- free(namedfm[i].fname);
+ xfree(namedfm[i].fname);
for (; i > NMARKS; --i)
namedfm[i] = namedfm[i - 1];
namedfm[NMARKS].fmark.mark = curwin->w_cursor;
@@ -1293,7 +1293,7 @@ static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2)
}
if (fm->fmark.fnum != 0)
- free(name);
+ xfree(name);
}
/*
@@ -1317,7 +1317,7 @@ int removable(char_u *name)
}
}
}
- free(name);
+ xfree(name);
return retval;
}
@@ -1474,7 +1474,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags
count++;
}
}
- free(str);
+ xfree(str);
pos.coladd = 0;
while (!(eof = viminfo_readline(virp)) && line[0] == TAB) {
@@ -1520,5 +1520,5 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags
break;
}
}
- free(name_buf);
+ xfree(name_buf);
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index fd6050f2d6..e45d43270a 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -523,7 +523,7 @@ char_u * mb_init(void)
convert_setup(&vimconv, p_enc, (char_u *)"utf-8");
vimconv.vc_fail = true;
}
- free(p);
+ xfree(p);
}
#endif
@@ -549,7 +549,7 @@ char_u * mb_init(void)
*/
p = string_convert(&vimconv, (char_u *)buf, NULL);
if (p != NULL) {
- free(p);
+ xfree(p);
n = 1;
} else
n = 2;
@@ -3103,7 +3103,7 @@ void utf_find_illegal(void)
for (;; ) {
p = get_cursor_pos_ptr();
if (vimconv.vc_type != CONV_NONE) {
- free(tofree);
+ xfree(tofree);
tofree = string_convert(&vimconv, p, NULL);
if (tofree == NULL)
break;
@@ -3142,7 +3142,7 @@ void utf_find_illegal(void)
beep_flush();
theend:
- free(tofree);
+ xfree(tofree);
convert_setup(&vimconv, NULL, NULL);
}
@@ -3375,7 +3375,7 @@ char_u *enc_canonize(char_u *enc) FUNC_ATTR_NONNULL_RET
STRMOVE(r, p);
} else if ((i = enc_alias_search(p)) >= 0) {
/* alias recognized, get canonical name */
- free(r);
+ xfree(r);
r = vim_strsave((char_u *)enc_canon_table[i].name);
}
return r;
@@ -3537,7 +3537,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, size_t slen,
p = xmalloc(len);
if (done > 0)
memmove(p, result, done);
- free(result);
+ xfree(result);
result = p;
}
@@ -3582,7 +3582,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, size_t slen,
fromlen -= l;
} else if (ICONV_ERRNO != ICONV_E2BIG) {
/* conversion failed */
- free(result);
+ xfree(result);
result = NULL;
break;
}
@@ -3891,7 +3891,7 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr,
if (l_w == 0) {
/* Illegal utf-8 byte cannot be converted */
- free(retval);
+ xfree(retval);
return NULL;
}
if (unconvlenp != NULL && l_w > len - i) {
@@ -3925,7 +3925,7 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr,
if (c < 0x100)
*d++ = c;
else if (vcp->vc_fail) {
- free(retval);
+ xfree(retval);
return NULL;
} else {
*d++ = 0xbf;
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 26542759be..bbe2e62021 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -99,7 +99,7 @@ memfile_T *mf_open(char_u *fname, int flags)
mf_do_open(mfp, fname, flags);
if (mfp->mf_fd < 0) { // fail if file could not be opened
- free(mfp);
+ xfree(mfp);
return NULL;
}
}
@@ -210,12 +210,12 @@ void mf_close(memfile_T *mfp, bool del_file)
mf_free_bhdr(hp);
}
while (mfp->mf_free_first != NULL) // free entries in free list
- free(mf_rem_free(mfp));
+ xfree(mf_rem_free(mfp));
mf_hash_free(&mfp->mf_hash);
mf_hash_free_all(&mfp->mf_trans); // free hashtable and its items
- free(mfp->mf_fname);
- free(mfp->mf_ffname);
- free(mfp);
+ xfree(mfp->mf_fname);
+ xfree(mfp->mf_ffname);
+ xfree(mfp);
}
/// Close the swap file for a memfile. Used when 'swapfile' is reset.
@@ -242,8 +242,8 @@ void mf_close_file(buf_T *buf, bool getlines)
if (mfp->mf_fname != NULL) {
os_remove((char *)mfp->mf_fname); // delete the swap file
- free(mfp->mf_fname);
- free(mfp->mf_ffname);
+ xfree(mfp->mf_fname);
+ xfree(mfp->mf_ffname);
mfp->mf_fname = NULL;
mfp->mf_ffname = NULL;
}
@@ -302,7 +302,7 @@ bhdr_T *mf_new(memfile_T *mfp, bool negative, unsigned page_count)
} else { // use the number, remove entry from free list
freep = mf_rem_free(mfp);
hp->bh_bnum = freep->bh_bnum;
- free(freep);
+ xfree(freep);
}
} else { // get a new number
if (hp == NULL) {
@@ -398,11 +398,11 @@ void mf_put(memfile_T *mfp, bhdr_T *hp, bool dirty, bool infile)
/// Signal block as no longer used (may put it in the free list).
void mf_free(memfile_T *mfp, bhdr_T *hp)
{
- free(hp->bh_data); // free data
+ xfree(hp->bh_data); // free data
mf_rem_hash(mfp, hp); // get *hp out of the hash list
mf_rem_used(mfp, hp); // get *hp out of the used list
if (hp->bh_bnum < 0) {
- free(hp); // don't want negative numbers in free list
+ xfree(hp); // don't want negative numbers in free list
mfp->mf_neg_count--;
} else {
mf_ins_free(mfp, hp); // put *hp in the free list
@@ -627,7 +627,7 @@ static bhdr_T *mf_release(memfile_T *mfp, unsigned page_count)
/// Make sure page_count of bh_data is right.
if (hp->bh_page_count != page_count) {
- free(hp->bh_data);
+ xfree(hp->bh_data);
hp->bh_data = xmalloc(mfp->mf_page_size * page_count);
hp->bh_page_count = page_count;
}
@@ -682,8 +682,8 @@ static bhdr_T *mf_alloc_bhdr(memfile_T *mfp, unsigned page_count)
/// Free a block header and its block memory.
static void mf_free_bhdr(bhdr_T *hp)
{
- free(hp->bh_data);
- free(hp);
+ xfree(hp->bh_data);
+ xfree(hp);
}
/// Insert a block in the free list.
@@ -843,7 +843,7 @@ static int mf_trans_add(memfile_T *mfp, bhdr_T *hp)
freep->bh_page_count -= page_count;
} else {
freep = mf_rem_free(mfp);
- free(freep);
+ xfree(freep);
}
} else {
new_bnum = mfp->mf_blocknr_max;
@@ -881,7 +881,7 @@ blocknr_T mf_trans_del(memfile_T *mfp, blocknr_T old_nr)
// remove entry from the trans list
mf_hash_rem_item(&mfp->mf_trans, (mf_hashitem_T *)np);
- free(np);
+ xfree(np);
return new_bnum;
}
@@ -902,7 +902,7 @@ void mf_set_ffname(memfile_T *mfp)
void mf_fullname(memfile_T *mfp)
{
if (mfp != NULL && mfp->mf_fname != NULL && mfp->mf_ffname != NULL) {
- free(mfp->mf_fname);
+ xfree(mfp->mf_fname);
mfp->mf_fname = mfp->mf_ffname;
mfp->mf_ffname = NULL;
}
@@ -940,8 +940,8 @@ static void mf_do_open(memfile_T *mfp, char_u *fname, int flags)
// If the file cannot be opened, use memory only
if (mfp->mf_fd < 0) {
- free(mfp->mf_fname);
- free(mfp->mf_ffname);
+ xfree(mfp->mf_fname);
+ xfree(mfp->mf_ffname);
mfp->mf_fname = NULL;
mfp->mf_ffname = NULL;
} else {
@@ -979,7 +979,7 @@ static void mf_hash_init(mf_hashtab_T *mht)
static void mf_hash_free(mf_hashtab_T *mht)
{
if (mht->mht_buckets != mht->mht_small_buckets)
- free(mht->mht_buckets);
+ xfree(mht->mht_buckets);
}
/// Free the array of a hash table and all the items it contains.
@@ -990,7 +990,7 @@ static void mf_hash_free_all(mf_hashtab_T *mht)
for (size_t idx = 0; idx <= mht->mht_mask; idx++)
for (mf_hashitem_T *mhi = mht->mht_buckets[idx]; mhi != NULL; mhi = next) {
next = mhi->mhi_next;
- free(mhi);
+ xfree(mhi);
}
mf_hash_free(mht);
@@ -1088,7 +1088,7 @@ static void mf_hash_grow(mf_hashtab_T *mht)
}
if (mht->mht_buckets != mht->mht_small_buckets)
- free(mht->mht_buckets);
+ xfree(mht->mht_buckets);
mht->mht_buckets = buckets;
mht->mht_mask = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR - 1;
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 448f15cc07..a72dc43eb4 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -373,7 +373,7 @@ error:
if (mfp != NULL) {
if (hp)
mf_put(mfp, hp, false, false);
- mf_close(mfp, true); /* will also free(mfp->mf_fname) */
+ mf_close(mfp, true); /* will also xfree(mfp->mf_fname) */
}
buf->b_ml.ml_mfp = NULL;
return FAIL;
@@ -418,7 +418,7 @@ void ml_setname(buf_T *buf)
/* if the file name is the same we don't have to do anything */
if (fnamecmp(fname, mfp->mf_fname) == 0) {
- free(fname);
+ xfree(fname);
success = TRUE;
break;
}
@@ -431,14 +431,14 @@ void ml_setname(buf_T *buf)
/* try to rename the swap file */
if (vim_rename(mfp->mf_fname, fname) == 0) {
success = TRUE;
- free(mfp->mf_fname);
+ xfree(mfp->mf_fname);
mfp->mf_fname = fname;
- free(mfp->mf_ffname);
+ xfree(mfp->mf_ffname);
mf_set_ffname(mfp);
ml_upd_block0(buf, UB_SAME_DIR);
break;
}
- free(fname); /* this fname didn't work, try another */
+ xfree(fname); /* this fname didn't work, try another */
}
if (mfp->mf_fd == -1) { /* need to (re)open the swap file */
@@ -567,9 +567,9 @@ void ml_close(buf_T *buf, int del_file)
return;
mf_close(buf->b_ml.ml_mfp, del_file); /* close the .swp file */
if (buf->b_ml.ml_line_lnum != 0 && (buf->b_ml.ml_flags & ML_LINE_DIRTY))
- free(buf->b_ml.ml_line_ptr);
- free(buf->b_ml.ml_stack);
- free(buf->b_ml.ml_chunksize);
+ xfree(buf->b_ml.ml_line_ptr);
+ xfree(buf->b_ml.ml_stack);
+ xfree(buf->b_ml.ml_chunksize);
buf->b_ml.ml_chunksize = NULL;
buf->b_ml.ml_mfp = NULL;
@@ -935,7 +935,7 @@ void ml_recover(void)
/* need to reallocate the memory used to store the data */
p = xmalloc(mfp->mf_page_size);
memmove(p, hp->bh_data, previous_page_size);
- free(hp->bh_data);
+ xfree(hp->bh_data);
hp->bh_data = p;
b0p = hp->bh_data;
}
@@ -1008,7 +1008,7 @@ void ml_recover(void)
set_fileformat(b0_ff - 1, OPT_LOCAL);
if (b0_fenc != NULL) {
set_option_value((char_u *)"fenc", 0L, b0_fenc, OPT_LOCAL);
- free(b0_fenc);
+ xfree(b0_fenc);
}
unchanged(curbuf, TRUE);
@@ -1194,7 +1194,7 @@ void ml_recover(void)
/* Need to copy one line, fetching the other one may flush it. */
p = vim_strsave(ml_get(idx));
i = STRCMP(p, ml_get(idx + lnum));
- free(p);
+ xfree(p);
if (i != 0) {
changed_int();
++curbuf->b_changedtick;
@@ -1237,16 +1237,16 @@ void ml_recover(void)
redraw_curbuf_later(NOT_VALID);
theend:
- free(fname_used);
+ xfree(fname_used);
recoverymode = FALSE;
if (mfp != NULL) {
if (hp != NULL)
mf_put(mfp, hp, false, false);
- mf_close(mfp, false); /* will also free(mfp->mf_fname) */
+ mf_close(mfp, false); /* will also xfree(mfp->mf_fname) */
}
if (buf != NULL) { //may be NULL if swap file not found.
- free(buf->b_ml.ml_stack);
- free(buf);
+ xfree(buf->b_ml.ml_stack);
+ xfree(buf);
}
if (serious_error && called_from_main)
ml_close(curbuf, TRUE);
@@ -1348,7 +1348,7 @@ recover_names (
tail = concat_fnames(dir_name, tail, TRUE);
}
num_names = recov_file_names(names, tail, FALSE);
- free(tail);
+ xfree(tail);
}
}
@@ -1372,7 +1372,7 @@ recover_names (
swapname = NULL;
num_files = 1;
}
- free(swapname);
+ xfree(swapname);
}
}
@@ -1386,9 +1386,9 @@ recover_names (
/* Remove the name from files[i]. Move further entries
* down. When the array becomes empty free it here, since
* FreeWild() won't be called below. */
- free(files[i]);
+ xfree(files[i]);
if (--num_files == 0)
- free(files);
+ xfree(files);
else
for (; i < num_files; ++i)
files[i] = files[i + 1];
@@ -1429,11 +1429,11 @@ recover_names (
file_count += num_files;
for (int i = 0; i < num_names; ++i)
- free(names[i]);
+ xfree(names[i]);
if (num_files > 0)
FreeWild(num_files, files);
}
- free(dir_name);
+ xfree(dir_name);
return file_count;
}
@@ -1453,8 +1453,8 @@ static char_u *make_percent_swname(char_u *dir, char_u *name)
if (vim_ispathsep(*d))
*d = '%';
d = concat_fnames(dir, s, TRUE);
- free(s);
- free(f);
+ xfree(s);
+ xfree(f);
}
return d;
}
@@ -1582,7 +1582,7 @@ static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
if (STRCMP(p, names[num_names]) != 0)
++num_names;
else
- free(names[num_names]);
+ xfree(names[num_names]);
} else
++num_names;
@@ -2339,7 +2339,7 @@ int ml_replace(linenr_T lnum, char_u *line, int copy)
if (curbuf->b_ml.ml_line_lnum != lnum) /* other line buffered */
ml_flush_line(curbuf); /* flush it */
else if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) /* same line allocated */
- free(curbuf->b_ml.ml_line_ptr); /* free it */
+ xfree(curbuf->b_ml.ml_line_ptr); /* free it */
curbuf->b_ml.ml_line_ptr = line;
curbuf->b_ml.ml_line_lnum = lnum;
curbuf->b_ml.ml_flags = (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;
@@ -2694,7 +2694,7 @@ static void ml_flush_line(buf_T *buf)
(void)ml_delete_int(buf, lnum, FALSE);
}
}
- free(new_line);
+ xfree(new_line);
entered = FALSE;
}
@@ -2938,7 +2938,7 @@ static int ml_add_stack(buf_T *buf)
infoptr_T *newstack = xmalloc(sizeof(infoptr_T) *
(buf->b_ml.ml_stack_size + STACK_INCR));
memmove(newstack, buf->b_ml.ml_stack, (size_t)top * sizeof(infoptr_T));
- free(buf->b_ml.ml_stack);
+ xfree(buf->b_ml.ml_stack);
buf->b_ml.ml_stack = newstack;
buf->b_ml.ml_stack_size += STACK_INCR;
}
@@ -3070,7 +3070,7 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name
r = NULL;
if ((s = make_percent_swname(dir_name, fname)) != NULL) {
r = modname(s, (char_u *)".swp", FALSE);
- free(s);
+ xfree(s);
}
return r;
}
@@ -3089,7 +3089,7 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name
return NULL;
s = get_file_in_dir(r, dir_name);
- free(r);
+ xfree(r);
return s;
}
@@ -3129,7 +3129,7 @@ get_file_in_dir (
t = concat_fnames(fname, dname + 2, TRUE);
*tail = save_char;
retval = concat_fnames(t, tail, TRUE);
- free(t);
+ xfree(t);
}
} else {
retval = concat_fnames(dname, tail, TRUE);
@@ -3264,7 +3264,7 @@ findswapname (
if (fname == NULL) /* must be out of memory */
break;
if ((n = (int)STRLEN(fname)) == 0) { /* safety check */
- free(fname);
+ xfree(fname);
fname = NULL;
break;
}
@@ -3394,7 +3394,7 @@ findswapname (
if (process_still_running && choice >= 4)
choice++; /* Skip missing "Delete it" button */
# endif
- free(name);
+ xfree(name);
/* pretend screen didn't scroll, need redraw anyway */
msg_scrolled = 0;
@@ -3447,7 +3447,7 @@ findswapname (
if (fname[n - 1] == 'a') { /* ".s?a" */
if (fname[n - 2] == 'a') { /* ".saa": tried enough, give up */
EMSG(_("E326: Too many swap files found"));
- free(fname);
+ xfree(fname);
fname = NULL;
break;
}
@@ -3457,7 +3457,7 @@ findswapname (
--fname[n - 1]; /* ".swo", ".swn", etc. */
}
- free(dir_name);
+ xfree(dir_name);
return fname;
}
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index 2223b65a93..35409aef49 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -92,6 +92,12 @@ void *xmalloc(size_t size)
return ret;
}
+/// free wrapper that returns delegates to the backing memory manager
+void xfree(void *ptr)
+{
+ free(ptr);
+}
+
/// calloc() wrapper
///
/// @see {xmalloc}
@@ -541,8 +547,8 @@ void free_all_mem(void)
clear_sb_text(); /* free any scrollback text */
/* Free some global vars. */
- free(last_cmdline);
- free(new_last_cmdline);
+ xfree(last_cmdline);
+ xfree(new_last_cmdline);
set_keep_msg(NULL, 0);
/* Clear cmdline history. */
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 8d9b5045b9..1689e7419e 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -188,7 +188,7 @@ ex_menu (
if (modes & (1 << i)) {
p = popup_mode_name(menu_path, i);
menu_nable_recurse(root_menu, p, MENU_ALL_MODES, enable);
- free(p);
+ xfree(p);
}
}
menu_nable_recurse(root_menu, menu_path, modes, enable);
@@ -207,7 +207,7 @@ ex_menu (
if (modes & (1 << i)) {
p = popup_mode_name(menu_path, i);
remove_menu(&root_menu, p, MENU_ALL_MODES, TRUE);
- free(p);
+ xfree(p);
}
}
@@ -241,11 +241,11 @@ ex_menu (
// Include all modes, to make ":amenu" work
menuarg.modes = modes;
add_menu_path(p, &menuarg, pri_tab, map_to);
- free(p);
+ xfree(p);
}
}
- free(map_buf);
+ xfree(map_buf);
}
@@ -391,12 +391,12 @@ add_menu_path (
menup = &menu->children;
parent = menu;
name = next_name;
- free(dname);
+ xfree(dname);
dname = NULL;
if (pri_tab[pri_idx + 1] != -1)
++pri_idx;
}
- free(path_name);
+ xfree(path_name);
/*
* Only add system menu items which have not been defined yet.
@@ -470,8 +470,8 @@ add_menu_path (
return OK;
erret:
- free(path_name);
- free(dname);
+ xfree(path_name);
+ xfree(dname);
/* Delete any empty submenu we added before discovering the error. Repeat
* for higher levels. */
@@ -663,14 +663,14 @@ static void free_menu(vimmenu_T **menup)
/* Don't change *menup until after calling gui_mch_destroy_menu(). The
* MacOS code needs the original structure to properly delete the menu. */
*menup = menu->next;
- free(menu->name);
- free(menu->dname);
- free(menu->en_name);
- free(menu->en_dname);
- free(menu->actext);
+ xfree(menu->name);
+ xfree(menu->dname);
+ xfree(menu->en_name);
+ xfree(menu->en_dname);
+ xfree(menu->actext);
for (i = 0; i < MENU_MODES; i++)
free_menu_string(menu, i);
- free(menu);
+ xfree(menu);
}
@@ -686,7 +686,7 @@ static void free_menu_string(vimmenu_T *menu, int idx)
if (menu->strings[i] == menu->strings[idx])
count++;
if (count == 1)
- free(menu->strings[idx]);
+ xfree(menu->strings[idx]);
menu->strings[idx] = NULL;
}
@@ -711,11 +711,11 @@ static int show_menus(char_u *path_name, int modes)
/* Found menu */
if (*p != NUL && menu->children == NULL) {
EMSG(_(e_notsubmenu));
- free(path_name);
+ xfree(path_name);
return FAIL;
} else if ((menu->modes & modes) == 0x0) {
EMSG(_(e_othermode));
- free(path_name);
+ xfree(path_name);
return FAIL;
}
break;
@@ -724,14 +724,14 @@ static int show_menus(char_u *path_name, int modes)
}
if (menu == NULL) {
EMSG2(_(e_nomenu), name);
- free(path_name);
+ xfree(path_name);
return FAIL;
}
name = p;
parent = menu;
menu = menu->children;
}
- free(path_name);
+ xfree(path_name);
/* Now we have found the matching menu, and we list the mappings */
/* Highlight title */
@@ -893,7 +893,7 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
* Menu path continues, but we have reached a leaf.
* Or menu exists only in another mode.
*/
- free(path_name);
+ xfree(path_name);
return NULL;
}
break;
@@ -902,13 +902,13 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
}
if (menu == NULL) {
/* No menu found with the name we were looking for */
- free(path_name);
+ xfree(path_name);
return NULL;
}
name = p;
menu = menu->children;
}
- free(path_name);
+ xfree(path_name);
xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
xp->xp_pattern = after_dot;
@@ -1289,7 +1289,7 @@ void ex_emenu(exarg_T *eap)
menu = menu->children;
name = p;
}
- free(saved_name);
+ xfree(saved_name);
if (menu == NULL) {
EMSG2(_("E334: Menu not found: %s"), eap->arg);
return;
@@ -1410,7 +1410,7 @@ vimmenu_T *gui_find_menu(char_u *path_name)
if (menu == NULL)
EMSG(_("E337: Menu not found - check menu names"));
theend:
- free(saved_name);
+ xfree(saved_name);
return menu;
}
#endif
@@ -1429,9 +1429,9 @@ static garray_T menutrans_ga = GA_EMPTY_INIT_VALUE;
#define FREE_MENUTRANS(mt) \
menutrans_T* _mt = (mt); \
- free(_mt->from); \
- free(_mt->from_noamp); \
- free(_mt->to)
+ xfree(_mt->from); \
+ xfree(_mt->from_noamp); \
+ xfree(_mt->to)
/*
* ":menutrans".
@@ -1514,11 +1514,11 @@ static char_u *menutrans_lookup(char_u *name, int len)
name[len] = c;
for (int i = 0; i < menutrans_ga.ga_len; i++) {
if (STRCMP(dname, tp[i].from_noamp) == 0) {
- free(dname);
+ xfree(dname);
return tp[i].to;
}
}
- free(dname);
+ xfree(dname);
return NULL;
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index b2e9488388..ae4d0ec230 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -200,7 +200,7 @@ msg_attr_keep (
* Columns + sc_col)
set_keep_msg(s, 0);
- free(buf);
+ xfree(buf);
--entered;
return retval;
}
@@ -362,7 +362,7 @@ static char_u *last_sourcing_name = NULL;
*/
void reset_last_sourcing(void)
{
- free(last_sourcing_name);
+ xfree(last_sourcing_name);
last_sourcing_name = NULL;
last_sourcing_lnum = 0;
}
@@ -433,18 +433,18 @@ void msg_source(int attr)
p = get_emsg_source();
if (p != NULL) {
msg_attr(p, attr);
- free(p);
+ xfree(p);
}
p = get_emsg_lnum();
if (p != NULL) {
msg_attr(p, hl_attr(HLF_N));
- free(p);
+ xfree(p);
last_sourcing_lnum = sourcing_lnum; /* only once for each line */
}
/* remember the last sourcing name printed, also when it's empty */
if (sourcing_name == NULL || other_sourcing_name()) {
- free(last_sourcing_name);
+ xfree(last_sourcing_name);
if (sourcing_name == NULL)
last_sourcing_name = NULL;
else
@@ -525,13 +525,13 @@ int emsg(char_u *s)
if (p != NULL) {
STRCAT(p, "\n");
redir_write(p, -1);
- free(p);
+ xfree(p);
}
p = get_emsg_lnum();
if (p != NULL) {
STRCAT(p, "\n");
redir_write(p, -1);
- free(p);
+ xfree(p);
}
redir_write(s, -1);
return TRUE;
@@ -726,8 +726,8 @@ int delete_first_msg(void)
assert(msg_hist_len == 1);
last_msg_hist = NULL;
}
- free(p->msg);
- free(p);
+ xfree(p->msg);
+ xfree(p);
--msg_hist_len;
return OK;
}
@@ -949,7 +949,7 @@ void wait_return(int redraw)
reset_last_sourcing();
if (keep_msg != NULL && vim_strsize(keep_msg) >=
(Rows - cmdline_row - 1) * Columns + sc_col) {
- free(keep_msg);
+ xfree(keep_msg);
keep_msg = NULL; /* don't redisplay message, it's too long */
}
@@ -985,7 +985,7 @@ static void hit_return_msg(void)
*/
void set_keep_msg(char_u *s, int attr)
{
- free(keep_msg);
+ xfree(keep_msg);
if (s != NULL && msg_silent == 0)
keep_msg = vim_strsave(s);
else
@@ -1002,7 +1002,7 @@ void msg_start(void)
int did_return = FALSE;
if (!msg_silent) {
- free(keep_msg);
+ xfree(keep_msg);
keep_msg = NULL; /* don't display old message now */
}
@@ -1088,7 +1088,7 @@ static void msg_home_replace_attr(char_u *fname, int attr)
name = home_replace_save(NULL, fname);
msg_outtrans_attr(name, attr);
- free(name);
+ xfree(name);
}
/*
@@ -1808,7 +1808,7 @@ static void inc_msg_scrolled(void)
p = tofree;
}
set_vim_var_string(VV_SCROLLSTART, p, -1);
- free(tofree);
+ xfree(tofree);
}
++msg_scrolled;
}
@@ -1879,7 +1879,7 @@ void clear_sb_text(void)
while (last_msgchunk != NULL) {
mp = last_msgchunk->sb_prev;
- free(last_msgchunk);
+ xfree(last_msgchunk);
last_msgchunk = mp;
}
}
@@ -2586,7 +2586,7 @@ void give_warning(char_u *message, bool hl) FUNC_ATTR_NONNULL_ARG(1)
++no_wait_return;
set_vim_var_string(VV_WARNINGMSG, message, -1);
- free(keep_msg);
+ xfree(keep_msg);
keep_msg = NULL;
if (hl)
keep_msg_attr = hl_attr(HLF_W);
@@ -2715,7 +2715,7 @@ do_dialog (
break;
}
- free(hotkeys);
+ xfree(hotkeys);
State = oldState;
setmouse();
@@ -2816,7 +2816,7 @@ static char_u * console_dialog_alloc(const char_u *message,
// Now allocate space for the strings
- free(confirm_msg);
+ xfree(confirm_msg);
confirm_msg = xmalloc(len);
*confirm_msg = NUL;
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index e58ec71e77..d8b84293c3 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -929,16 +929,16 @@ open_line (
curwin->w_cursor.col = 0;
curwin->w_cursor.coladd = 0;
ins_bytes(p_extra); /* will call changed_bytes() */
- free(p_extra);
+ xfree(p_extra);
next_line = NULL;
}
retval = TRUE; /* success! */
theend:
curbuf->b_p_pi = saved_pi;
- free(saved_line);
- free(next_line);
- free(allocated);
+ xfree(saved_line);
+ xfree(next_line);
+ xfree(allocated);
return retval;
}
@@ -2432,7 +2432,7 @@ int get_keystroke(void)
#endif
break;
}
- free(buf);
+ xfree(buf);
mapped_ctrl_c = save_mapped_ctrl_c;
return n;
@@ -2784,7 +2784,7 @@ get_cmd_output (
call_shell(command, kShellOptDoOut | kShellOptExpand | flags, NULL);
--no_check_timestamps;
- free(command);
+ xfree(command);
/*
* read the names from the file into memory
@@ -2806,7 +2806,7 @@ get_cmd_output (
os_remove((char *)tempname);
if (i != len) {
EMSG2(_(e_notread), tempname);
- free(buffer);
+ xfree(buffer);
buffer = NULL;
} else if (ret_len == NULL) {
/* Change NUL into SOH, otherwise the string is truncated. */
@@ -2820,7 +2820,7 @@ get_cmd_output (
}
done:
- free(tempname);
+ xfree(tempname);
return buffer;
}
@@ -2833,8 +2833,8 @@ void FreeWild(int count, char_u **files)
if (count <= 0 || files == NULL)
return;
while (count--)
- free(files[count]);
- free(files);
+ xfree(files[count]);
+ xfree(files);
}
/*
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c
index 79b42cabf0..7a584d4ea1 100644
--- a/src/nvim/misc2.c
+++ b/src/nvim/misc2.c
@@ -329,10 +329,10 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
: STRCMP(p_sxq, "\"(") == 0 ? (char_u *)")\""
: p_sxq);
retval = os_call_shell(ncmd, opts, extra_shell_arg);
- free(ncmd);
+ xfree(ncmd);
if (ecmd != cmd)
- free(ecmd);
+ xfree(ecmd);
}
}
@@ -387,7 +387,7 @@ int vim_chdir(char_u *new_dir)
if (dir_name == NULL)
return -1;
r = os_chdir((char *)dir_name);
- free(dir_name);
+ xfree(dir_name);
return r;
}
@@ -453,7 +453,7 @@ char *read_string(FILE *fd, size_t cnt)
for (size_t i = 0; i < cnt; i++) {
int c = getc(fd);
if (c == EOF) {
- free(str);
+ xfree(str);
return NULL;
}
str[i] = (uint8_t)c;
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 34879e425e..fc0409e137 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -478,9 +478,9 @@ static void on_request_event(Event event)
result,
&out_buffer));
// All arguments were freed already, but we still need to free the array
- free(args.items);
+ xfree(args.items);
decref(channel);
- free(e);
+ xfree(e);
}
static bool channel_write(Channel *channel, WBuffer *buffer)
@@ -601,7 +601,7 @@ static void unsubscribe(Channel *channel, char *event)
// Since the string is no longer used by other channels, release it's memory
pmap_del(cstr_t)(event_strings, event_string);
- free(event_string);
+ xfree(event_string);
}
/// Close the channel streams/job and free the channel resources.
@@ -655,13 +655,13 @@ static void free_channel(Channel *channel)
pmap_free(cstr_t)(channel->subscribed_events);
kv_destroy(channel->call_stack);
kv_destroy(channel->delayed_notifications);
- free(channel);
+ xfree(channel);
}
static void close_cb(uv_handle_t *handle)
{
- free(handle->data);
- free(handle);
+ xfree(handle->data);
+ xfree(handle);
}
static Channel *register_channel(void)
@@ -738,7 +738,7 @@ static WBuffer *serialize_request(uint64_t channel_id,
WBuffer *rv = wstream_new_buffer(xmemdup(sbuffer->data, sbuffer->size),
sbuffer->size,
refcount,
- free);
+ xfree);
msgpack_sbuffer_clear(sbuffer);
api_free_array(args);
return rv;
@@ -757,7 +757,7 @@ static WBuffer *serialize_response(uint64_t channel_id,
WBuffer *rv = wstream_new_buffer(xmemdup(sbuffer->data, sbuffer->size),
sbuffer->size,
1, // responses only go though 1 channel
- free);
+ xfree);
msgpack_sbuffer_clear(sbuffer);
api_free_object(arg);
return rv;
diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c
index b554d76bed..07d78dd9d7 100644
--- a/src/nvim/msgpack_rpc/remote_ui.c
+++ b/src/nvim/msgpack_rpc/remote_ui.c
@@ -48,9 +48,9 @@ void remote_ui_disconnect(uint64_t channel_id)
// destroy pending screen updates
api_free_array(data->buffer);
pmap_del(uint64_t)(connected_uis, channel_id);
- free(ui->data);
+ xfree(ui->data);
ui_detach(ui);
- free(ui);
+ xfree(ui);
}
static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c
index 91aca0c37a..c03531ca0c 100644
--- a/src/nvim/msgpack_rpc/server.c
+++ b/src/nvim/msgpack_rpc/server.c
@@ -57,7 +57,7 @@ bool server_init(void)
if (!os_getenv(LISTEN_ADDRESS_ENV_VAR)) {
char *listen_address = (char *)vim_tempname();
os_setenv(LISTEN_ADDRESS_ENV_VAR, listen_address, 1);
- free(listen_address);
+ xfree(listen_address);
}
return server_start((char *)os_getenv(LISTEN_ADDRESS_ENV_VAR)) == 0;
@@ -256,10 +256,10 @@ static void connection_cb(uv_stream_t *server, int status)
static void free_client(uv_handle_t *handle)
{
- free(handle);
+ xfree(handle);
}
static void free_server(uv_handle_t *handle)
{
- free(handle->data);
+ xfree(handle->data);
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 4fcf6f9594..0dbaf52b7e 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -980,7 +980,7 @@ getcount:
/* now reset it, otherwise it's put in the history again */
keep_msg = kmsg;
msg_attr(kmsg, keep_msg_attr);
- free(kmsg);
+ xfree(kmsg);
}
setcursor();
ui_flush();
@@ -1015,7 +1015,7 @@ normal_end:
clear_showcmd();
checkpcmark(); /* check if we moved since setting pcmark */
- free(ca.searchbuf);
+ xfree(ca.searchbuf);
if (has_mbyte)
mb_adjust_cursor();
@@ -1160,7 +1160,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
else {
AppendToRedobuffLit(repeat_cmdline, -1);
AppendToRedobuff(NL_STR);
- free(repeat_cmdline);
+ xfree(repeat_cmdline);
repeat_cmdline = NULL;
}
}
@@ -3342,7 +3342,7 @@ find_decl (
reset_search_dir();
}
- free(pat);
+ xfree(pat);
p_ws = save_p_ws;
p_scs = save_p_scs;
@@ -4261,7 +4261,7 @@ static void nv_ident(cmdarg_T *cap)
}
if (n == 0) {
EMSG(_(e_noident)); /* found dashes only */
- free(buf);
+ xfree(buf);
return;
}
@@ -4312,11 +4312,11 @@ static void nv_ident(cmdarg_T *cap)
/* Escape the argument properly for a shell command */
ptr = vim_strnsave(ptr, n);
p = vim_strsave_shellescape(ptr, true, true);
- free(ptr);
+ xfree(ptr);
newbuf = (char_u *)xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);
buf = newbuf;
STRCAT(buf, p);
- free(p);
+ xfree(p);
} else {
if (cmdchar == '*')
aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
@@ -4365,7 +4365,7 @@ static void nv_ident(cmdarg_T *cap)
} else
do_cmdline_cmd(buf);
- free(buf);
+ xfree(buf);
}
/*
@@ -4724,7 +4724,7 @@ static void nv_gotofile(cmdarg_T *cap)
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
}
- free(ptr);
+ xfree(ptr);
} else
clearop(cap->oap);
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 6c67063739..85b1244fa3 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -668,7 +668,7 @@ int get_expr_register(void)
if (new_line == NULL)
return NUL;
if (*new_line == NUL) /* use previous line */
- free(new_line);
+ xfree(new_line);
else
set_expr_line(new_line);
return '=';
@@ -680,7 +680,7 @@ int get_expr_register(void)
*/
void set_expr_line(char_u *new_line)
{
- free(expr_line);
+ xfree(expr_line);
expr_line = new_line;
}
@@ -709,7 +709,7 @@ char_u *get_expr_line(void)
++nested;
rv = eval_to_string(expr_copy, NULL, TRUE);
--nested;
- free(expr_copy);
+ xfree(expr_copy);
return rv;
}
@@ -843,7 +843,7 @@ void put_register(int name, void *reg)
get_yank_register(name, YREG_PUT);
free_yank_all();
*y_current = *(struct yankreg *)reg;
- free(reg);
+ xfree(reg);
set_clipboard(name);
}
@@ -923,11 +923,11 @@ static int stuff_yank(int regname, char_u *p)
{
/* check for read-only register */
if (regname != 0 && !valid_yank_reg(regname, TRUE)) {
- free(p);
+ xfree(p);
return FAIL;
}
if (regname == '_') { /* black hole: don't do anything */
- free(p);
+ xfree(p);
return OK;
}
get_yank_register(regname, YREG_YANK);
@@ -937,8 +937,8 @@ static int stuff_yank(int regname, char_u *p)
STRCPY(lp, *pp);
// TODO(philix): use xstpcpy() in stuff_yank()
STRCAT(lp, p);
- free(p);
- free(*pp);
+ xfree(p);
+ xfree(*pp);
*pp = lp;
} else {
free_yank_all();
@@ -992,7 +992,7 @@ do_execreg (
EMSG(_(e_nolastcmd));
return FAIL;
}
- free(new_last_cmdline); /* don't keep the cmdline containing @: */
+ xfree(new_last_cmdline); /* don't keep the cmdline containing @: */
new_last_cmdline = NULL;
/* Escape all control characters with a CTRL-V */
p = vim_strsave_escaped_ext(
@@ -1006,13 +1006,13 @@ do_execreg (
retval = put_in_typebuf(p + 5, TRUE, TRUE, silent);
else
retval = put_in_typebuf(p, TRUE, TRUE, silent);
- free(p);
+ xfree(p);
} else if (regname == '=') {
p = get_expr_line();
if (p == NULL)
return FAIL;
retval = put_in_typebuf(p, TRUE, colon, silent);
- free(p);
+ xfree(p);
} else if (regname == '.') { /* use last inserted text */
p = get_last_insert_save();
if (p == NULL) {
@@ -1020,7 +1020,7 @@ do_execreg (
return FAIL;
}
retval = put_in_typebuf(p, FALSE, colon, silent);
- free(p);
+ xfree(p);
} else {
get_yank_register(regname, YREG_PASTE);
if (y_current->y_array == NULL)
@@ -1044,7 +1044,7 @@ do_execreg (
}
escaped = vim_strsave_escape_csi(y_current->y_array[i]);
retval = ins_typebuf(escaped, remap, 0, TRUE, silent);
- free(escaped);
+ xfree(escaped);
if (retval == FAIL)
return FAIL;
if (colon && ins_typebuf((char_u *)":", remap, 0, TRUE, silent)
@@ -1110,7 +1110,7 @@ put_in_typebuf (
retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES,
0, TRUE, silent);
if (esc)
- free(p);
+ xfree(p);
}
if (colon && retval == OK)
retval = ins_typebuf((char_u *)":", REMAP_NONE, 0, TRUE, silent);
@@ -1154,7 +1154,7 @@ insert_reg (
return FAIL;
stuffescaped(arg, literally);
if (allocated)
- free(arg);
+ xfree(arg);
} else { /* name or number register */
get_yank_register(regname, YREG_PASTE);
if (y_current->y_array == NULL)
@@ -1804,7 +1804,7 @@ int op_replace(oparg_T *oap, int c)
ml_append(curwin->w_cursor.lnum++, after_p, 0, FALSE);
appended_lines_mark(curwin->w_cursor.lnum, 1L);
oap->end.lnum++;
- free(after_p);
+ xfree(after_p);
}
}
} else {
@@ -2186,7 +2186,7 @@ void op_insert(oparg_T *oap, long count1)
curwin->w_cursor.col = oap->start.col;
check_cursor();
- free(ins_text);
+ xfree(ins_text);
}
}
}
@@ -2299,7 +2299,7 @@ int op_change(oparg_T *oap)
}
check_cursor();
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
- free(ins_text);
+ xfree(ins_text);
}
}
@@ -2341,9 +2341,9 @@ static void free_yank(long n)
long i;
for (i = n; --i >= 0; ) {
- free(y_current->y_array[i]);
+ xfree(y_current->y_array[i]);
}
- free(y_current->y_array);
+ xfree(y_current->y_array);
y_current->y_array = NULL;
}
}
@@ -2507,7 +2507,7 @@ int op_yank(oparg_T *oap, int deleting, int mess)
new_ptr = xmalloc(sizeof(char_u *) * (curr->y_size + y_current->y_size));
for (j = 0; j < curr->y_size; ++j)
new_ptr[j] = curr->y_array[j];
- free(curr->y_array);
+ xfree(curr->y_array);
curr->y_array = new_ptr;
if (yanktype == MLINE) /* MLINE overrides MCHAR and MBLOCK */
@@ -2520,8 +2520,8 @@ int op_yank(oparg_T *oap, int deleting, int mess)
+ STRLEN(y_current->y_array[0]) + 1);
STRCPY(pnew, curr->y_array[--j]);
STRCAT(pnew, y_current->y_array[0]);
- free(curr->y_array[j]);
- free(y_current->y_array[0]);
+ xfree(curr->y_array[j]);
+ xfree(y_current->y_array[0]);
curr->y_array[j++] = pnew;
y_idx = 1;
} else
@@ -2529,7 +2529,7 @@ int op_yank(oparg_T *oap, int deleting, int mess)
while (y_idx < y_current->y_size)
curr->y_array[j++] = y_current->y_array[y_idx++];
curr->y_size = j;
- free(y_current->y_array);
+ xfree(y_current->y_array);
y_current = curr;
}
if (curwin->w_p_rnu) {
@@ -2735,7 +2735,7 @@ do_put (
goto end;
ptr = vim_strsave(get_cursor_pos_ptr());
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
- free(ptr);
+ xfree(ptr);
ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col);
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
@@ -3049,7 +3049,7 @@ do_put (
STRCAT(newp, ptr);
/* insert second line */
ml_append(lnum, newp, (colnr_T)0, FALSE);
- free(newp);
+ xfree(newp);
oldp = ml_get(lnum);
newp = (char_u *) xmalloc((size_t)(col + yanklen + 1));
@@ -3154,9 +3154,9 @@ error:
end:
if (allocated)
- free(insert_string);
+ xfree(insert_string);
if (regname == '=')
- free(y_array);
+ xfree(y_array);
VIsual_active = FALSE;
@@ -3618,9 +3618,9 @@ int do_join(long count,
curwin->w_set_curswant = TRUE;
theend:
- free(spaces);
+ xfree(spaces);
if (remove_comments)
- free(comments);
+ xfree(comments);
return ret;
}
@@ -3681,7 +3681,7 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in
while (vim_iswhite(line1[idx1]))
++idx1;
}
- free(line1);
+ xfree(line1);
return idx2 == leader2_len && idx1 == leader1_len;
}
@@ -4479,7 +4479,7 @@ int do_addsub(int command, linenr_T Prenum1)
*ptr = NUL;
STRCAT(buf1, buf2);
ins_str(buf1); /* insert the new number */
- free(buf1);
+ xfree(buf1);
}
--curwin->w_cursor.col;
curwin->w_set_curswant = TRUE;
@@ -4556,7 +4556,7 @@ int read_viminfo_register(vir_T *virp, int force)
if (do_it) {
if (size == 0) {
- free(array);
+ xfree(array);
} else if (size < limit) {
y_current->y_array = xrealloc(array, size * sizeof(char_u *));
} else {
@@ -5018,7 +5018,7 @@ static void str_to_reg(struct yankreg *y_ptr, int yank_type, const char_u *str,
ssize_t s_len = extra + line_len;
if (append) {
- free(pp[lnum]);
+ xfree(pp[lnum]);
append = false; // only first line is appended
}
pp[lnum] = s;
@@ -5430,7 +5430,7 @@ static bool get_clipboard(int name, struct yankreg** target, bool quiet)
// a known-to-be charwise yank might have a final linebreak
// but otherwise there is no line after the final newline
if (reg->y_type != MCHAR) {
- free(reg->y_array[reg->y_size-1]);
+ xfree(reg->y_array[reg->y_size-1]);
reg->y_size--;
if (reg->y_type == MAUTO) {
reg->y_type = MLINE;
@@ -5459,9 +5459,9 @@ static bool get_clipboard(int name, struct yankreg** target, bool quiet)
err:
if (reg->y_array) {
for (int i = 0; i < reg->y_size; i++) {
- free(reg->y_array[i]);
+ xfree(reg->y_array[i]);
}
- free(reg->y_array);
+ xfree(reg->y_array);
}
reg->y_array = NULL;
reg->y_size = 0;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 7e5410ff63..23a23a0814 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1827,11 +1827,11 @@ void set_init_1(void)
ga.ga_len += len;
}
if (mustfree)
- free(p);
+ xfree(p);
}
if (ga.ga_data != NULL) {
set_string_default("bsk", ga.ga_data);
- free(ga.ga_data);
+ xfree(ga.ga_data);
}
}
@@ -1885,10 +1885,10 @@ void set_init_1(void)
options[opt_idx].def_val[VI_DEFAULT] = buf;
options[opt_idx].flags |= P_DEF_ALLOCED;
} else
- free(buf); /* cannot happen */
+ xfree(buf); /* cannot happen */
}
if (mustfree)
- free(cdpath);
+ xfree(cdpath);
}
}
@@ -1958,7 +1958,7 @@ void set_init_1(void)
* split P_DEF_ALLOCED in two.
*/
if (options[opt_idx].flags & P_DEF_ALLOCED)
- free(options[opt_idx].def_val[VI_DEFAULT]);
+ xfree(options[opt_idx].def_val[VI_DEFAULT]);
options[opt_idx].def_val[VI_DEFAULT] = p;
options[opt_idx].flags |= P_DEF_ALLOCED;
}
@@ -1998,7 +1998,7 @@ void set_init_1(void)
* for practical purposes, thus use that. It's not an alias to
* still support conversion between gb18030 and utf-8. */
p_enc = vim_strsave((char_u *)"cp936");
- free(p);
+ xfree(p);
}
if (mb_init() == NULL) {
opt_idx = findoption((char_u *)"encoding");
@@ -2028,7 +2028,7 @@ void set_init_1(void)
#endif
} else {
- free(p_enc);
+ xfree(p_enc);
// mb_init() failed; fallback to utf8 and try again.
p_enc = save_enc;
mb_init();
@@ -2136,7 +2136,7 @@ void set_string_default(const char *name, const char_u *val)
int opt_idx = findoption((char_u *)name);
if (opt_idx >= 0) {
if (options[opt_idx].flags & P_DEF_ALLOCED) {
- free(options[opt_idx].def_val[VI_DEFAULT]);
+ xfree(options[opt_idx].def_val[VI_DEFAULT]);
}
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) xstrdup((char *) val);
@@ -2276,7 +2276,7 @@ void set_init_3(void)
options[idx_srr].def_val[VI_DEFAULT] = p_srr;
}
}
- free(p);
+ xfree(p);
}
#endif
@@ -2782,7 +2782,7 @@ do_set (
(char_u *)"indent,eol,start");
break;
}
- free(oldval);
+ xfree(oldval);
oldval = *(char_u **)varp;
}
/*
@@ -2879,7 +2879,7 @@ do_set (
|| (flags & P_COMMA)) {
s = option_expand(opt_idx, newval);
if (s != NULL) {
- free(newval);
+ xfree(newval);
newlen = (unsigned)STRLEN(s) + 1;
if (adding || prepending || removing)
newlen += (unsigned)STRLEN(origval) + 1;
@@ -3373,13 +3373,13 @@ void check_buf_options(buf_T *buf)
void free_string_option(char_u *p)
{
if (p != empty_option)
- free(p);
+ xfree(p);
}
void clear_string_option(char_u **pp)
{
if (*pp != empty_option)
- free(*pp);
+ xfree(*pp);
*pp = empty_option;
}
@@ -3768,7 +3768,7 @@ did_set_string_option (
if (errmsg == NULL) {
/* canonize the value, so that STRCMP() can be used on it */
p = enc_canonize(*varp);
- free(*varp);
+ xfree(*varp);
*varp = p;
if (varp == &p_enc) {
errmsg = mb_init();
@@ -3795,7 +3795,7 @@ did_set_string_option (
} else if (varp == &p_penc) {
/* Canonize printencoding if VIM standard one */
p = enc_canonize(p_penc);
- free(p_penc);
+ xfree(p_penc);
p_penc = p;
} else if (varp == &curbuf->b_p_keymap) {
/* load or unload key mapping tables */
@@ -4456,7 +4456,7 @@ skip:
return e_invarg; /* illegal trailing comma as in "set cc=80," */
}
- free(wp->w_p_cc_cols);
+ xfree(wp->w_p_cc_cols);
if (count == 0)
wp->w_p_cc_cols = NULL;
else {
@@ -4649,7 +4649,7 @@ static char_u *compile_cap_prog(synblock_T *synblock)
/* Prepend a ^ so that we only match at one column */
re = concat_str((char_u *)"^", synblock->b_p_spc);
synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
- free(re);
+ xfree(re);
if (synblock->b_cap_prog == NULL) {
synblock->b_cap_prog = rp; /* restore the previous program */
return e_invarg;
@@ -5930,7 +5930,7 @@ showoptions (
os_breakcheck();
}
}
- free(items);
+ xfree(items);
}
/*
@@ -6157,10 +6157,10 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e
buf = xmalloc(MAXPATHL);
home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
if (put_escstr(fd, buf, 2) == FAIL) {
- free(buf);
+ xfree(buf);
return FAIL;
}
- free(buf);
+ xfree(buf);
} else if (put_escstr(fd, *valuep, 2) == FAIL)
return FAIL;
}
@@ -7438,10 +7438,10 @@ void vimrc_found(char_u *fname, char_u *envname)
p = FullName_save(fname, FALSE);
if (p != NULL) {
vim_setenv(envname, p);
- free(p);
+ xfree(p);
}
} else if (dofree)
- free(p);
+ xfree(p);
}
}
@@ -7608,7 +7608,7 @@ void save_file_ff(buf_T *buf)
/* Only use free/alloc when necessary, they take time. */
if (buf->b_start_fenc == NULL
|| STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) {
- free(buf->b_start_fenc);
+ xfree(buf->b_start_fenc);
buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
}
}
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index fd6237c5b0..37158f4d3c 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -113,7 +113,7 @@ void init_homedir(void)
char_u *var;
/* In case we are called a second time (when 'encoding' changes). */
- free(homedir);
+ xfree(homedir);
homedir = NULL;
var = (char_u *)os_getenv("HOME");
@@ -144,7 +144,7 @@ void init_homedir(void)
void free_homedir(void)
{
- free(homedir);
+ xfree(homedir);
}
#endif
@@ -304,7 +304,7 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
char_u *p = vim_strsave(var);
if (mustfree) {
- free(var);
+ xfree(var);
}
var = p;
mustfree = true;
@@ -318,7 +318,7 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
char_u *p = vim_strsave_escaped(var, (char_u *)" \t");
if (mustfree)
- free(var);
+ xfree(var);
var = p;
mustfree = true;
}
@@ -341,7 +341,7 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
copy_char = false;
}
if (mustfree)
- free(var);
+ xfree(var);
}
if (copy_char) { /* copy at least one char */
@@ -380,11 +380,11 @@ static char *vim_version_dir(char *vimdir)
p = concat_fnames((char_u *)vimdir, (char_u *)VIM_VERSION_NODOT, true);
if (os_isdir(p))
return (char *)p;
- free(p);
+ xfree(p);
p = concat_fnames((char_u *)vimdir, (char_u *)RUNTIME_DIRNAME, true);
if (os_isdir(p))
return (char *)p;
- free(p);
+ xfree(p);
return NULL;
}
@@ -483,7 +483,7 @@ char_u *vim_getenv(char_u *name, bool *mustfree)
p = vim_strnsave(p, (size_t)(pend - p));
if (!os_isdir(p)) {
- free(p);
+ xfree(p);
p = NULL;
} else {
*mustfree = true;
@@ -634,7 +634,7 @@ void home_replace(buf_T *buf, char_u *src, char_u *dst, int dstlen, bool one)
*dst = NUL;
if (homedir_env != homedir_env_orig)
- free(homedir_env);
+ xfree(homedir_env);
}
/// Like home_replace, store the replaced string in allocated memory.
@@ -663,7 +663,7 @@ void vim_setenv(char_u *name, char_u *val)
if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) {
char_u *buf = concat_str(val, (char_u *)"/lang");
bindtextdomain(VIMPACKAGE, (char *)buf);
- free(buf);
+ xfree(buf);
}
}
@@ -678,7 +678,7 @@ char_u *get_env_name(expand_T *xp, int idx)
char *envname = os_getenvname_at_index((size_t)idx);
if (envname) {
STRLCPY(name, envname, ENVNAMELEN);
- free(envname);
+ xfree(envname);
return name;
} else {
return NULL;
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index d583323b1f..2a41001cde 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -152,14 +152,14 @@ static bool is_executable_in_path(const char_u *name, char_u **abspath)
*abspath = save_absolute_path(buf);
}
- free(buf);
+ xfree(buf);
return true;
}
if (*e != ':') {
// End of $PATH without finding any executable called name.
- free(buf);
+ xfree(buf);
return false;
}
diff --git a/src/nvim/os/job_private.h b/src/nvim/os/job_private.h
index af13d2e636..983106d918 100644
--- a/src/nvim/os/job_private.h
+++ b/src/nvim/os/job_private.h
@@ -11,6 +11,7 @@
#include "nvim/os/pty_process.h"
#include "nvim/os/shell.h"
#include "nvim/log.h"
+#include "nvim/memory.h"
struct job {
// Job id the index in the job table plus one.
@@ -104,12 +105,12 @@ static inline void job_decref(Job *job)
// Invoke the exit_cb
job_exit_callback(job);
// Free all memory allocated for the job
- free(job->proc_stdin->data);
- free(job->proc_stdout->data);
- free(job->proc_stderr->data);
+ xfree(job->proc_stdin->data);
+ xfree(job->proc_stdout->data);
+ xfree(job->proc_stderr->data);
shell_free_argv(job->opts.argv);
process_destroy(job);
- free(job);
+ xfree(job);
}
}
diff --git a/src/nvim/os/pipe_process.c b/src/nvim/os/pipe_process.c
index 5535c3fe93..2ac305e967 100644
--- a/src/nvim/os/pipe_process.c
+++ b/src/nvim/os/pipe_process.c
@@ -72,8 +72,8 @@ void pipe_process_init(Job *job)
void pipe_process_destroy(Job *job)
{
UvProcess *pipeproc = job->process;
- free(pipeproc->proc.data);
- free(pipeproc);
+ xfree(pipeproc->proc.data);
+ xfree(pipeproc);
job->process = NULL;
}
diff --git a/src/nvim/os/pty_process.c b/src/nvim/os/pty_process.c
index 9a2721f769..c64f3f9932 100644
--- a/src/nvim/os/pty_process.c
+++ b/src/nvim/os/pty_process.c
@@ -65,8 +65,8 @@ void pty_process_init(Job *job) FUNC_ATTR_NONNULL_ALL
void pty_process_destroy(Job *job) FUNC_ATTR_NONNULL_ALL
{
- free(job->opts.term_name);
- free(job->process);
+ xfree(job->opts.term_name);
+ xfree(job->process);
job->process = NULL;
}
diff --git a/src/nvim/os/rstream.c b/src/nvim/os/rstream.c
index 29b8a5a9e1..702f282d53 100644
--- a/src/nvim/os/rstream.c
+++ b/src/nvim/os/rstream.c
@@ -162,8 +162,8 @@ size_t rbuffer_available(RBuffer *rbuffer)
void rbuffer_free(RBuffer *rbuffer)
{
- free(rbuffer->data);
- free(rbuffer);
+ xfree(rbuffer->data);
+ xfree(rbuffer);
}
/// Creates a new RStream instance. A RStream encapsulates all the boilerplate
@@ -216,7 +216,7 @@ void rstream_free(RStream *rstream)
}
rbuffer_free(rstream->buffer);
- free(rstream);
+ xfree(rstream);
}
/// Sets the underlying `uv_stream_t` instance
@@ -401,8 +401,8 @@ static void fread_idle_cb(uv_idle_t *handle)
static void close_cb(uv_handle_t *handle)
{
- free(handle->data);
- free(handle);
+ xfree(handle->data);
+ xfree(handle);
}
static void rbuffer_relocate(RBuffer *rbuffer)
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 6fcb62a5f3..4f5928ba8a 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -80,11 +80,11 @@ void shell_free_argv(char **argv)
while (*p != NULL) {
// Free each argument
- free(*p);
+ xfree(*p);
p++;
}
- free(argv);
+ xfree(argv);
}
/// Calls the user-configured 'shell' (p_sh) for running a command or wildcard
@@ -128,11 +128,11 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
emsg_silent,
forward_output);
- free(input.data);
+ xfree(input.data);
if (output) {
(void)write_output(output, nread, true, true);
- free(output);
+ xfree(output);
}
if (!emsg_silent && status != 0 && !(opts & kShellOptSilent)) {
@@ -250,7 +250,7 @@ static int shell(const char *cmd,
if (buf.len == 0) {
// no data received from the process, return NULL
*output = NULL;
- free(buf.data);
+ xfree(buf.data);
} else {
// NUL-terminate to make the output directly usable as a C string
buf.data[buf.len] = NUL;
diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c
index ad9d936625..73896c381d 100644
--- a/src/nvim/os/wstream.c
+++ b/src/nvim/os/wstream.c
@@ -76,7 +76,7 @@ void wstream_free(WStream *wstream) {
uv_close((uv_handle_t *)wstream->stream, close_cb);
} else {
handle_set_wstream((uv_handle_t *)wstream->stream, NULL);
- free(wstream);
+ xfree(wstream);
}
} else {
wstream->freed = true;
@@ -157,7 +157,7 @@ bool wstream_write(WStream *wstream, WBuffer *buffer)
uvbuf.len = buffer->size;
if (uv_write(&data->uv_req, wstream->stream, &uvbuf, 1, write_cb)) {
- free(data);
+ xfree(data);
goto err;
}
@@ -216,11 +216,11 @@ static void write_cb(uv_write_t *req, int status)
if (data->wstream->free_handle) {
uv_close((uv_handle_t *)data->wstream->stream, close_cb);
} else {
- free(data->wstream);
+ xfree(data->wstream);
}
}
- free(data);
+ xfree(data);
}
void wstream_release_wbuffer(WBuffer *buffer)
@@ -230,14 +230,14 @@ void wstream_release_wbuffer(WBuffer *buffer)
buffer->cb(buffer->data);
}
- free(buffer);
+ xfree(buffer);
}
}
static void close_cb(uv_handle_t *handle)
{
- free(handle_get_wstream(handle));
- free(handle->data);
- free(handle);
+ xfree(handle_get_wstream(handle));
+ xfree(handle->data);
+ xfree(handle);
}
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 26a4cdb083..e69b5ccc27 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -435,11 +435,11 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
if (ampersent)
os_delay(10L, true);
- free(command);
+ xfree(command);
if (i) { /* os_call_shell() failed */
os_remove((char *)tempname);
- free(tempname);
+ xfree(tempname);
/*
* With interactive completion, the error message is not printed.
*/
@@ -472,18 +472,18 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
MSG(_(e_wildexpand));
msg_start(); /* don't overwrite this message */
}
- free(tempname);
+ xfree(tempname);
goto notfound;
}
int fseek_res = fseek(fd, 0L, SEEK_END);
if (fseek_res < 0) {
- free(tempname);
+ xfree(tempname);
fclose(fd);
return FAIL;
}
long long templen = ftell(fd); /* get size of temp file */
if (templen < 0) {
- free(tempname);
+ xfree(tempname);
fclose(fd);
return FAIL;
}
@@ -501,11 +501,11 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
if (readlen != len) {
/* unexpected read error */
EMSG2(_(e_notread), tempname);
- free(tempname);
- free(buffer);
+ xfree(tempname);
+ xfree(buffer);
return FAIL;
}
- free(tempname);
+ xfree(tempname);
/* file names are separated with Space */
if (shell_style == STYLE_ECHO) {
@@ -574,7 +574,7 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
* /bin/sh will happily expand it to nothing rather than returning an
* error; and hey, it's good to check anyway -- webb.
*/
- free(buffer);
+ xfree(buffer);
goto notfound;
}
*num_file = i;
@@ -628,11 +628,11 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
add_pathsep(p); /* add '/' to a directory name */
(*file)[j++] = p;
}
- free(buffer);
+ xfree(buffer);
*num_file = j;
if (*num_file == 0) { /* rejected all entries */
- free(*file);
+ xfree(*file);
*file = NULL;
goto notfound;
}
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 80f1947ccf..36d550b764 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -380,7 +380,7 @@ FullName_save (
} else {
new_fname = vim_strsave(fname);
}
- free(buf);
+ xfree(buf);
return new_fname;
}
@@ -557,7 +557,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
starts_with_dot = (*s == '.');
pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
if (pat == NULL) {
- free(buf);
+ xfree(buf);
return 0;
}
@@ -574,10 +574,10 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
if (flags & (EW_NOERROR | EW_NOTWILD))
--emsg_silent;
- free(pat);
+ xfree(pat);
if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0) {
- free(buf);
+ xfree(buf);
return 0;
}
@@ -634,7 +634,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
os_closedir(&dir);
}
- free(buf);
+ xfree(buf);
vim_regfree(regmatch.regprog);
matches = gap->ga_len - start_len;
@@ -750,7 +750,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
GA_APPEND(char_u *, gap, vim_strsave(buf));
}
- free(buf);
+ xfree(buf);
}
/*
@@ -819,13 +819,13 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
file_pattern[1] = NUL;
STRCAT(file_pattern, pattern);
pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, TRUE);
- free(file_pattern);
+ xfree(file_pattern);
if (pat == NULL)
return;
regmatch.rm_ic = TRUE; /* always ignore case */
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
- free(pat);
+ xfree(pat);
if (regmatch.regprog == NULL)
return;
@@ -910,16 +910,16 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
add_pathsep(rel_path);
STRCAT(rel_path, short_name);
- free(fnames[i]);
+ xfree(fnames[i]);
fnames[i] = rel_path;
sort_again = TRUE;
os_breakcheck();
}
- free(curdir);
+ xfree(curdir);
for (int i = 0; i < gap->ga_len; i++)
- free(in_curdir[i]);
- free(in_curdir);
+ xfree(in_curdir[i]);
+ xfree(in_curdir);
ga_clear_strings(&path_ga);
vim_regfree(regmatch.regprog);
@@ -978,7 +978,7 @@ expand_in_path (
ga_init(&path_ga, (int)sizeof(char_u *), 1);
expand_path_option(curdir, &path_ga);
- free(curdir);
+ xfree(curdir);
if (GA_EMPTY(&path_ga))
return 0;
@@ -986,7 +986,7 @@ expand_in_path (
ga_clear_strings(&path_ga);
globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0);
- free(paths);
+ xfree(paths);
return gap->ga_len;
}
@@ -1110,7 +1110,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
* found file names and start all over again.
*/
else if (has_env_var(p) || *p == '~') {
- free(p);
+ xfree(p);
ga_clear_strings(&ga);
i = mch_expand_wildcards(num_pat, pat, num_file, file,
flags | EW_KEEPDOLLAR);
@@ -1154,13 +1154,13 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
addfile(&ga, t, flags | EW_DIR | EW_FILE);
else if (os_file_exists(t))
addfile(&ga, t, flags);
- free(t);
+ xfree(t);
}
if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH))
uniquefy_paths(&ga, p);
if (p != pat[i])
- free(p);
+ xfree(p);
}
*num_file = ga.ga_len;
@@ -1206,7 +1206,7 @@ expand_backtick (
else
buffer = get_cmd_output(cmd, NULL,
(flags & EW_SILENT) ? kShellOptSilent : 0, NULL);
- free(cmd);
+ xfree(cmd);
if (buffer == NULL)
return 0;
@@ -1229,7 +1229,7 @@ expand_backtick (
++cmd;
}
- free(buffer);
+ xfree(buffer);
return cnt;
}
@@ -1509,13 +1509,13 @@ find_file_name_in_path (
/* Repeat finding the file "count" times. This matters when it
* appears several times in the path. */
while (file_name != NULL && --count > 0) {
- free(file_name);
+ xfree(file_name);
file_name = find_file_in_path(ptr, len, options, FALSE, rel_fname);
}
} else
file_name = vim_strnsave(ptr, len);
- free(tofree);
+ xfree(tofree);
return file_name;
}
@@ -1793,7 +1793,7 @@ char_u *path_shorten_fname_if_possible(char_u *full_path)
p = full_path;
}
}
- free(dirname);
+ xfree(dirname);
return p;
}
@@ -1854,8 +1854,8 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
if (eval_pat != NULL) {
- free(exp_pat);
- free(eval_pat);
+ xfree(exp_pat);
+ xfree(eval_pat);
}
return ret;
@@ -1903,13 +1903,13 @@ int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file,
break;
if (match_file_list(p_wig, (*file)[i], ffname)) {
/* remove this matching file from the list */
- free((*file)[i]);
+ xfree((*file)[i]);
for (j = i; j + 1 < *num_file; ++j)
(*file)[j] = (*file)[j + 1];
--*num_file;
--i;
}
- free(ffname);
+ xfree(ffname);
}
}
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 7ef962fa2f..10012a9775 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -18,6 +18,7 @@
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
+#include "nvim/memory.h"
#include "nvim/window.h"
#include "nvim/edit.h"
@@ -377,12 +378,12 @@ void pum_redraw(void)
}
}
screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1, attr);
- free(rt_start);
- free(st);
+ xfree(rt_start);
+ xfree(st);
col -= width;
} else {
screen_puts_len(st, (int)STRLEN(st), row, col, attr);
- free(st);
+ xfree(st);
col += width;
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 8e55cced78..7e83132a25 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -784,15 +784,15 @@ qf_init_ok:
for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first) {
fmt_first = fmt_ptr->next;
vim_regfree(fmt_ptr->prog);
- free(fmt_ptr);
+ xfree(fmt_ptr);
}
qf_clean_dir_stack(&dir_stack);
qf_clean_dir_stack(&file_stack);
qf_init_end:
- free(namebuf);
- free(errmsg);
- free(pattern);
- free(fmtstr);
+ xfree(namebuf);
+ xfree(errmsg);
+ xfree(pattern);
+ xfree(fmtstr);
qf_update_buffer(qi);
@@ -855,7 +855,7 @@ static void ll_free_all(qf_info_T **pqi)
/* No references to this location list */
for (i = 0; i < qi->qf_listcount; ++i)
qf_free(qi, i);
- free(qi);
+ xfree(qi);
}
}
@@ -1091,7 +1091,7 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
* directory change.
*/
if (!os_file_exists(ptr)) {
- free(ptr);
+ xfree(ptr);
directory = qf_guess_filepath(fname);
if (directory)
ptr = concat_fnames(directory, fname, TRUE);
@@ -1100,7 +1100,7 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
}
/* Use concatenated directory name and file name */
fnum = buflist_add(ptr, 0);
- free(ptr);
+ xfree(ptr);
return fnum;
}
return buflist_add(fname, 0);
@@ -1134,7 +1134,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
ds_new = (*stackptr)->next;
(*stackptr)->dirname = NULL;
while (ds_new) {
- free((*stackptr)->dirname);
+ xfree((*stackptr)->dirname);
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
TRUE);
if (os_isdir((*stackptr)->dirname))
@@ -1147,13 +1147,13 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
while ((*stackptr)->next != ds_new) {
ds_ptr = (*stackptr)->next;
(*stackptr)->next = (*stackptr)->next->next;
- free(ds_ptr->dirname);
- free(ds_ptr);
+ xfree(ds_ptr->dirname);
+ xfree(ds_ptr);
}
/* Nothing found -> it must be on top level */
if (ds_new == NULL) {
- free((*stackptr)->dirname);
+ xfree((*stackptr)->dirname);
(*stackptr)->dirname = vim_strsave(dirbuf);
}
}
@@ -1163,7 +1163,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
else {
ds_ptr = *stackptr;
*stackptr = (*stackptr)->next;
- free(ds_ptr);
+ xfree(ds_ptr);
return NULL;
}
}
@@ -1184,8 +1184,8 @@ static char_u *qf_pop_dir(struct dir_stack_T **stackptr)
if (*stackptr != NULL) {
ds_ptr = *stackptr;
*stackptr = (*stackptr)->next;
- free(ds_ptr->dirname);
- free(ds_ptr);
+ xfree(ds_ptr->dirname);
+ xfree(ds_ptr);
}
/* return NEW top element as current dir or NULL if stack is empty*/
@@ -1201,8 +1201,8 @@ static void qf_clean_dir_stack(struct dir_stack_T **stackptr)
while ((ds_ptr = *stackptr) != NULL) {
*stackptr = (*stackptr)->next;
- free(ds_ptr->dirname);
- free(ds_ptr);
+ xfree(ds_ptr->dirname);
+ xfree(ds_ptr);
}
}
@@ -1239,7 +1239,7 @@ static char_u *qf_guess_filepath(char_u *filename)
ds_ptr = dir_stack->next;
fullname = NULL;
while (ds_ptr) {
- free(fullname);
+ xfree(fullname);
fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
if (os_file_exists(fullname))
@@ -1248,14 +1248,14 @@ static char_u *qf_guess_filepath(char_u *filename)
ds_ptr = ds_ptr->next;
}
- free(fullname);
+ xfree(fullname);
/* clean up all dirs we already left */
while (dir_stack->next != ds_ptr) {
ds_tmp = dir_stack->next;
dir_stack->next = dir_stack->next->next;
- free(ds_tmp->dirname);
- free(ds_tmp);
+ xfree(ds_tmp->dirname);
+ xfree(ds_tmp);
}
return ds_ptr==NULL ? NULL : ds_ptr->dirname;
@@ -1876,10 +1876,10 @@ static void qf_free(qf_info_T *qi, int idx)
while (qi->qf_lists[idx].qf_count) {
qfp = qi->qf_lists[idx].qf_start->qf_next;
if (qi->qf_lists[idx].qf_title != NULL && !stop) {
- free(qi->qf_lists[idx].qf_start->qf_text);
+ xfree(qi->qf_lists[idx].qf_start->qf_text);
stop = (qi->qf_lists[idx].qf_start == qfp);
- free(qi->qf_lists[idx].qf_start->qf_pattern);
- free(qi->qf_lists[idx].qf_start);
+ xfree(qi->qf_lists[idx].qf_start->qf_pattern);
+ xfree(qi->qf_lists[idx].qf_start);
if (stop)
/* Somehow qf_count may have an incorrect value, set it to 1
* to avoid crashing when it's wrong.
@@ -1889,7 +1889,7 @@ static void qf_free(qf_info_T *qi, int idx)
qi->qf_lists[idx].qf_start = qfp;
--qi->qf_lists[idx].qf_count;
}
- free(qi->qf_lists[idx].qf_title);
+ xfree(qi->qf_lists[idx].qf_title);
qi->qf_lists[idx].qf_title = NULL;
qi->qf_lists[idx].qf_index = 0;
}
@@ -2526,8 +2526,8 @@ void ex_make(exarg_T *eap)
qf_jump(qi, 0, 0, FALSE); /* display first error */
os_remove((char *)fname);
- free(fname);
- free(cmd);
+ xfree(fname);
+ xfree(cmd);
}
/*
@@ -2573,7 +2573,7 @@ static char_u *get_mef_name(void)
if (!file_or_link_found) {
break;
}
- free(name);
+ xfree(name);
}
return name;
}
@@ -2834,7 +2834,7 @@ void ex_vimgrep(exarg_T *eap)
msg_outtrans(fname);
else {
msg_outtrans(p);
- free(p);
+ xfree(p);
}
msg_clr_eos();
msg_didout = FALSE; /* overwrite this message */
@@ -3021,9 +3021,9 @@ void ex_vimgrep(exarg_T *eap)
}
theend:
- free(dirname_now);
- free(dirname_start);
- free(target_dir);
+ xfree(dirname_now);
+ xfree(dirname_start);
+ xfree(target_dir);
vim_regfree(regmatch.regprog);
}
@@ -3091,7 +3091,7 @@ static void restore_start_dir(char_u *dirname_start)
ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
ex_cd(&ea);
}
- free(dirname_now);
+ xfree(dirname_now);
}
/*
@@ -3356,10 +3356,10 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title)
type == NULL ? NUL : *type,
valid);
- free(filename);
- free(pattern);
- free(text);
- free(type);
+ xfree(filename);
+ xfree(pattern);
+ xfree(text);
+ xfree(type);
if (status == FAIL) {
retval = FAIL;
@@ -3599,12 +3599,12 @@ void ex_helpgrep(exarg_T *eap)
) == FAIL) {
got_int = TRUE;
if (line != IObuff)
- free(line);
+ xfree(line);
break;
}
}
if (line != IObuff)
- free(line);
+ xfree(line);
++lnum;
line_breakcheck();
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index d5e963c2f8..a260860e17 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1265,7 +1265,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
regcode = r->program;
regc(REGMAGIC);
if (reg(REG_NOPAREN, &flags) == NULL || reg_toolong) {
- free(r);
+ xfree(r);
if (reg_toolong)
EMSG_RET_NULL(_("E339: Pattern too long"));
return NULL;
@@ -1349,7 +1349,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
*/
static void bt_regfree(regprog_T *prog)
{
- free(prog);
+ xfree(prog);
}
/*
@@ -3236,8 +3236,8 @@ void free_regexp_stuff(void)
{
ga_clear(&regstack);
ga_clear(&backpos);
- free(reg_tofree);
- free(reg_prev_sub);
+ xfree(reg_tofree);
+ xfree(reg_prev_sub);
}
#endif
@@ -3509,7 +3509,7 @@ theend:
/* Free "reg_tofree" when it's a bit big.
* Free regstack and backpos if they are bigger than their initial size. */
if (reg_tofreelen > 400) {
- free(reg_tofree);
+ xfree(reg_tofree);
reg_tofree = NULL;
}
if (regstack.ga_maxlen > REGSTACK_INITIAL)
@@ -3551,8 +3551,8 @@ void unref_extmatch(reg_extmatch_T *em)
if (em != NULL && --em->refcnt <= 0) {
for (i = 0; i < NSUBEXP; ++i)
- free(em->matches[i]);
- free(em);
+ xfree(em->matches[i]);
+ xfree(em);
}
}
@@ -5642,7 +5642,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
len = (int)STRLEN(regline);
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
len += 50; /* get some extra */
- free(reg_tofree);
+ xfree(reg_tofree);
reg_tofree = xmalloc(len);
reg_tofreelen = len;
}
@@ -6382,7 +6382,7 @@ char_u *regtilde(char_u *source, int magic)
STRCPY(tmpsub + len + prevlen, p + 1);
if (newsub != source) /* already allocated newsub */
- free(newsub);
+ xfree(newsub);
newsub = tmpsub;
p = newsub + len + prevlen;
} else if (magic)
@@ -6398,7 +6398,7 @@ char_u *regtilde(char_u *source, int magic)
}
}
- free(reg_prev_sub);
+ xfree(reg_prev_sub);
if (newsub != source) /* newsub was allocated, just keep it */
reg_prev_sub = newsub;
else /* no ~ found, need to save newsub */
@@ -6494,14 +6494,14 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in
if (eval_result != NULL) {
STRCPY(dest, eval_result);
dst += STRLEN(eval_result);
- free(eval_result);
+ xfree(eval_result);
eval_result = NULL;
}
} else {
win_T *save_reg_win;
int save_ireg_ic;
- free(eval_result);
+ xfree(eval_result);
/* The expression may contain substitute(), which calls us
* recursively. Make sure submatch() gets the text from the first
@@ -6542,7 +6542,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in
if (had_backslash && backslash) {
/* Backslashes will be consumed, need to double them. */
s = vim_strsave_escaped(eval_result, (char_u *)"\\");
- free(eval_result);
+ xfree(eval_result);
eval_result = s;
}
@@ -7073,7 +7073,7 @@ static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, bool nl)
result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);
}
- free(pat);
+ xfree(pat);
p_re = save_p_re;
}
@@ -7127,7 +7127,7 @@ long vim_regexec_multi(
tm);
}
- free(pat);
+ xfree(pat);
p_re = save_p_re;
}
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 1de167c40f..56e488fbd4 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -2886,7 +2886,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
if (stackp < stack) \
{ \
st_error(postfix, end, p); \
- free(stack); \
+ xfree(stack); \
return NULL; \
}
@@ -3317,13 +3317,13 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
e = POP();
if (stackp != stack) {
- free(stack);
+ xfree(stack);
EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA),"
"too many states left on stack"));
}
if (istate >= nstate) {
- free(stack);
+ xfree(stack);
EMSG_RET_NULL(_("E876: (NFA regexp) "
"Not enough space to store the whole NFA "));
}
@@ -3337,7 +3337,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
ret = e.start;
theend:
- free(stack);
+ xfree(stack);
return ret;
#undef POP1
@@ -4195,7 +4195,7 @@ addstate_here (
memmove(&(newl[listidx + count]),
&(l->t[listidx + 1]),
sizeof(nfa_thread_T) * (l->n - count - listidx - 1));
- free(l->t);
+ xfree(l->t);
l->t = newl;
} else {
/* make space for new states, then move them from the
@@ -6033,9 +6033,9 @@ nextchar:
theend:
/* Free memory */
- free(list[0].t);
- free(list[1].t);
- free(listids);
+ xfree(list[0].t);
+ xfree(list[1].t);
+ xfree(listids);
#undef ADD_STATE_IF_MATCH
#ifdef NFA_REGEXP_DEBUG_LOG
fclose(debug);
@@ -6340,13 +6340,13 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags)
nfa_regengine.expr = NULL;
out:
- free(post_start);
+ xfree(post_start);
post_start = post_ptr = post_end = NULL;
state_ptr = NULL;
return (regprog_T *)prog;
fail:
- free(prog);
+ xfree(prog);
prog = NULL;
#ifdef REGEXP_DEBUG
nfa_postfix_dump(expr, FAIL);
@@ -6361,9 +6361,9 @@ fail:
static void nfa_regfree(regprog_T *prog)
{
if (prog != NULL) {
- free(((nfa_regprog_T *)prog)->match_text);
- free(((nfa_regprog_T *)prog)->pattern);
- free(prog);
+ xfree(((nfa_regprog_T *)prog)->match_text);
+ xfree(((nfa_regprog_T *)prog)->pattern);
+ xfree(prog);
}
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index c32603afb0..acd8e925e0 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1905,7 +1905,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
}
if (text != buf)
- free(text);
+ xfree(text);
/*
* 6. set highlighting for the Visual area an other text.
@@ -3015,7 +3015,7 @@ win_line (
--n_extra;
} else {
if (p_extra_free != NULL) {
- free(p_extra_free);
+ xfree(p_extra_free);
p_extra_free = NULL;
}
/*
@@ -4700,7 +4700,7 @@ win_redr_status_matches (
}
win_redraw_last_status(topframe);
- free(buf);
+ xfree(buf);
}
/*
@@ -4915,7 +4915,7 @@ get_keymap_str (
sprintf((char *)buf, "<%s>", p);
else
buf[0] = NUL;
- free(s);
+ xfree(s);
}
return buf[0] != NUL;
}
@@ -5021,14 +5021,14 @@ win_redr_custom (
width = build_stl_str_hl(ewp, buf, sizeof(buf),
stl, use_sandbox,
fillchar, maxwidth, hltab, tabtab);
- free(stl);
+ xfree(stl);
ewp->w_p_crb = p_crb_save;
/* Make all characters printable. */
p = transstr(buf);
len = STRLCPY(buf, p, sizeof(buf));
len = (size_t)len < sizeof(buf) ? len : (int)sizeof(buf) - 1;
- free(p);
+ xfree(p);
/* fill up with "fillchar" */
while (width < maxwidth && len < (int)sizeof(buf) - 1) {
@@ -5999,23 +5999,23 @@ retry:
* and over again. */
done_outofmem_msg = TRUE;
}
- free(new_ScreenLines);
+ xfree(new_ScreenLines);
new_ScreenLines = NULL;
- free(new_ScreenLinesUC);
+ xfree(new_ScreenLinesUC);
new_ScreenLinesUC = NULL;
for (i = 0; i < p_mco; ++i) {
- free(new_ScreenLinesC[i]);
+ xfree(new_ScreenLinesC[i]);
new_ScreenLinesC[i] = NULL;
}
- free(new_ScreenLines2);
+ xfree(new_ScreenLines2);
new_ScreenLines2 = NULL;
- free(new_ScreenAttrs);
+ xfree(new_ScreenAttrs);
new_ScreenAttrs = NULL;
- free(new_LineOffset);
+ xfree(new_LineOffset);
new_LineOffset = NULL;
- free(new_LineWraps);
+ xfree(new_LineWraps);
new_LineWraps = NULL;
- free(new_TabPageIdxs);
+ xfree(new_TabPageIdxs);
new_TabPageIdxs = NULL;
} else {
done_outofmem_msg = FALSE;
@@ -6126,15 +6126,15 @@ void free_screenlines(void)
{
int i;
- free(ScreenLinesUC);
+ xfree(ScreenLinesUC);
for (i = 0; i < Screen_mco; ++i)
- free(ScreenLinesC[i]);
- free(ScreenLines2);
- free(ScreenLines);
- free(ScreenAttrs);
- free(LineOffset);
- free(LineWraps);
- free(TabPageIdxs);
+ xfree(ScreenLinesC[i]);
+ xfree(ScreenLines2);
+ xfree(ScreenLines);
+ xfree(ScreenAttrs);
+ xfree(LineOffset);
+ xfree(LineWraps);
+ xfree(TabPageIdxs);
}
void screenclear(void)
diff --git a/src/nvim/search.c b/src/nvim/search.c
index f62aeabd72..f015c233c8 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -179,7 +179,7 @@ search_regcomp (
add_to_history(HIST_SEARCH, pat, TRUE, NUL);
if (mr_pattern_alloced) {
- free(mr_pattern);
+ xfree(mr_pattern);
mr_pattern_alloced = FALSE;
}
@@ -249,7 +249,7 @@ char_u *reverse_text(char_u *s) FUNC_ATTR_NONNULL_RET
void save_re_pat(int idx, char_u *pat, int magic)
{
if (spats[idx].pat != pat) {
- free(spats[idx].pat);
+ xfree(spats[idx].pat);
spats[idx].pat = vim_strsave(pat);
spats[idx].magic = magic;
spats[idx].no_scs = no_smartcase;
@@ -284,10 +284,10 @@ void save_search_patterns(void)
void restore_search_patterns(void)
{
if (--save_level == 0) {
- free(spats[0].pat);
+ xfree(spats[0].pat);
spats[0] = saved_spats[0];
set_vv_searchforward();
- free(spats[1].pat);
+ xfree(spats[1].pat);
spats[1] = saved_spats[1];
last_idx = saved_last_idx;
SET_NO_HLSEARCH(saved_no_hlsearch);
@@ -297,11 +297,11 @@ void restore_search_patterns(void)
#if defined(EXITFREE)
void free_search_patterns(void)
{
- free(spats[0].pat);
- free(spats[1].pat);
+ xfree(spats[0].pat);
+ xfree(spats[1].pat);
if (mr_pattern_alloced) {
- free(mr_pattern);
+ xfree(mr_pattern);
mr_pattern_alloced = FALSE;
mr_pattern = NULL;
}
@@ -377,7 +377,7 @@ void reset_search_dir(void)
*/
void set_last_search_pat(const char_u *s, int idx, int magic, int setlast)
{
- free(spats[idx].pat);
+ xfree(spats[idx].pat);
/* An empty string means that nothing should be matched. */
if (*s == NUL)
spats[idx].pat = NULL;
@@ -393,7 +393,7 @@ void set_last_search_pat(const char_u *s, int idx, int magic, int setlast)
if (setlast)
last_idx = idx;
if (save_level) {
- free(saved_spats[idx].pat);
+ xfree(saved_spats[idx].pat);
saved_spats[idx] = spats[0];
if (spats[idx].pat == NULL)
saved_spats[idx].pat = NULL;
@@ -1075,17 +1075,17 @@ int do_search(
* left, but do reverse the text. */
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
char_u *r = reverse_text(trunc != NULL ? trunc : msgbuf);
- free(trunc);
+ xfree(trunc);
trunc = r;
}
if (trunc != NULL) {
msg_outtrans(trunc);
- free(trunc);
+ xfree(trunc);
} else
msg_outtrans(msgbuf);
msg_clr_eos();
msg_check();
- free(msgbuf);
+ xfree(msgbuf);
gotocmdline(FALSE);
ui_flush();
@@ -1203,7 +1203,7 @@ int do_search(
end_do_search:
if ((options & SEARCH_KEEP) || cmdmod.keeppatterns)
spats[0].off = old_off;
- free(strcopy);
+ xfree(strcopy);
return retval;
}
@@ -3246,8 +3246,8 @@ again:
r = do_searchpair(spat, (char_u *)"", epat, FORWARD, (char_u *)"",
0, NULL, (linenr_T)0, 0L);
- free(spat);
- free(epat);
+ xfree(spat);
+ xfree(epat);
if (r < 1 || lt(curwin->w_cursor, old_end)) {
/* Can't find other end or it's before the previous end. Could be a
@@ -4006,7 +4006,7 @@ find_pattern_in_path (
/* ignore case according to p_ic, p_scs and pat */
regmatch.rm_ic = ignorecase(pat);
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
- free(pat);
+ xfree(pat);
if (regmatch.regprog == NULL)
goto fpip_end;
}
@@ -4070,7 +4070,7 @@ find_pattern_in_path (
prev_fname = NULL;
}
}
- free(new_fname);
+ xfree(new_fname);
new_fname = NULL;
already_searched = TRUE;
break;
@@ -4173,17 +4173,17 @@ find_pattern_in_path (
bigger[i + max_path_depth] = files[i];
old_files += max_path_depth;
max_path_depth *= 2;
- free(files);
+ xfree(files);
files = bigger;
}
if ((files[depth + 1].fp = mch_fopen((char *)new_fname, "r"))
== NULL)
- free(new_fname);
+ xfree(new_fname);
else {
if (++depth == old_files) {
// Something wrong. We will forget one of our already visited files
// now.
- free(files[old_files].name);
+ xfree(files[old_files].name);
++old_files;
}
files[depth].name = curr_fname = new_fname;
@@ -4491,11 +4491,11 @@ exit_matched:
/* Close any files that are still open. */
for (i = 0; i <= depth; i++) {
fclose(files[i].fp);
- free(files[i].name);
+ xfree(files[i].name);
}
for (i = old_files; i < max_path_depth; i++)
- free(files[i].name);
- free(files);
+ xfree(files[i].name);
+ xfree(files);
if (type == CHECK_PATH) {
if (!did_show) {
@@ -4518,7 +4518,7 @@ exit_matched:
msg_end();
fpip_end:
- free(file_line);
+ xfree(file_line);
vim_regfree(regmatch.regprog);
vim_regfree(incl_regmatch.regprog);
vim_regfree(def_regmatch.regprog);
@@ -4629,7 +4629,7 @@ int read_viminfo_search_pattern(vir_T *virp, int force)
if (force || spats[idx].pat == NULL) {
val = viminfo_readstring(virp, (int)(lp - virp->vir_line + 1), TRUE);
set_last_search_pat(val, idx, magic, setlast);
- free(val);
+ xfree(val);
spats[idx].no_scs = no_scs;
spats[idx].off.line = off_line;
spats[idx].off.end = off_end;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 6708ad2aa7..7b38b540cb 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -2097,7 +2097,7 @@ spell_move_to (
len = (int)STRLEN(line);
if (buflen < len + MAXWLEN + 2) {
- free(buf);
+ xfree(buf);
buflen = len + MAXWLEN + 2;
buf = xmalloc(buflen);
}
@@ -2172,7 +2172,7 @@ spell_move_to (
if (dir == FORWARD) {
// No need to search further.
wp->w_cursor = found_pos;
- free(buf);
+ xfree(buf);
if (attrp != NULL)
*attrp = attr;
return len;
@@ -2195,7 +2195,7 @@ spell_move_to (
if (dir == BACKWARD && found_pos.lnum != 0) {
// Use the last match in the line (before the cursor).
wp->w_cursor = found_pos;
- free(buf);
+ xfree(buf);
return found_len;
}
@@ -2259,7 +2259,7 @@ spell_move_to (
line_breakcheck();
}
- free(buf);
+ xfree(buf);
return 0;
}
@@ -2376,26 +2376,26 @@ static slang_T *slang_alloc(char_u *lang)
// Free the contents of an slang_T and the structure itself.
static void slang_free(slang_T *lp)
{
- free(lp->sl_name);
- free(lp->sl_fname);
+ xfree(lp->sl_name);
+ xfree(lp->sl_fname);
slang_clear(lp);
- free(lp);
+ xfree(lp);
}
/// Frees a salitem_T
static void free_salitem(salitem_T *smp) {
- free(smp->sm_lead);
+ xfree(smp->sm_lead);
// Don't free sm_oneof and sm_rules, they point into sm_lead.
- free(smp->sm_to);
- free(smp->sm_lead_w);
- free(smp->sm_oneof_w);
- free(smp->sm_to_w);
+ xfree(smp->sm_to);
+ xfree(smp->sm_lead_w);
+ xfree(smp->sm_oneof_w);
+ xfree(smp->sm_to_w);
}
/// Frees a fromto_T
static void free_fromto(fromto_T *ftp) {
- free(ftp->ft_from);
- free(ftp->ft_to);
+ xfree(ftp->ft_from);
+ xfree(ftp->ft_to);
}
// Clear an slang_T so that the file can be reloaded.
@@ -2403,18 +2403,18 @@ static void slang_clear(slang_T *lp)
{
garray_T *gap;
- free(lp->sl_fbyts);
+ xfree(lp->sl_fbyts);
lp->sl_fbyts = NULL;
- free(lp->sl_kbyts);
+ xfree(lp->sl_kbyts);
lp->sl_kbyts = NULL;
- free(lp->sl_pbyts);
+ xfree(lp->sl_pbyts);
lp->sl_pbyts = NULL;
- free(lp->sl_fidxs);
+ xfree(lp->sl_fidxs);
lp->sl_fidxs = NULL;
- free(lp->sl_kidxs);
+ xfree(lp->sl_kidxs);
lp->sl_kidxs = NULL;
- free(lp->sl_pidxs);
+ xfree(lp->sl_pidxs);
lp->sl_pidxs = NULL;
GA_DEEP_CLEAR(&lp->sl_rep, fromto_T, free_fromto);
@@ -2433,25 +2433,25 @@ static void slang_clear(slang_T *lp)
vim_regfree(lp->sl_prefprog[i]);
}
lp->sl_prefixcnt = 0;
- free(lp->sl_prefprog);
+ xfree(lp->sl_prefprog);
lp->sl_prefprog = NULL;
- free(lp->sl_info);
+ xfree(lp->sl_info);
lp->sl_info = NULL;
- free(lp->sl_midword);
+ xfree(lp->sl_midword);
lp->sl_midword = NULL;
vim_regfree(lp->sl_compprog);
- free(lp->sl_comprules);
- free(lp->sl_compstartflags);
- free(lp->sl_compallflags);
+ xfree(lp->sl_comprules);
+ xfree(lp->sl_compstartflags);
+ xfree(lp->sl_compallflags);
lp->sl_compprog = NULL;
lp->sl_comprules = NULL;
lp->sl_compstartflags = NULL;
lp->sl_compallflags = NULL;
- free(lp->sl_syllable);
+ xfree(lp->sl_syllable);
lp->sl_syllable = NULL;
ga_clear(&lp->sl_syl_items);
@@ -2474,9 +2474,9 @@ static void slang_clear(slang_T *lp)
// Clear the info from the .sug file in "lp".
static void slang_clear_sug(slang_T *lp)
{
- free(lp->sl_sbyts);
+ xfree(lp->sl_sbyts);
lp->sl_sbyts = NULL;
- free(lp->sl_sidxs);
+ xfree(lp->sl_sidxs);
lp->sl_sidxs = NULL;
close_spellbuf(lp->sl_sugbuf);
lp->sl_sugbuf = NULL;
@@ -2642,7 +2642,7 @@ spell_load_file (
if (p == NULL)
goto endFAIL;
set_map_str(lp, p);
- free(p);
+ xfree(p);
break;
case SN_WORDS:
@@ -2799,7 +2799,7 @@ static int read_charflags_section(FILE *fd)
// <folcharslen> <folchars>
fol = read_cnt_string(fd, 2, &follen);
if (follen < 0) {
- free(flags);
+ xfree(flags);
return follen;
}
@@ -2807,8 +2807,8 @@ static int read_charflags_section(FILE *fd)
if (flags != NULL && fol != NULL)
set_spell_charflags(flags, flagslen, fol);
- free(flags);
- free(fol);
+ xfree(flags);
+ xfree(fol);
// When <charflagslen> is zero then <fcharlen> must also be zero.
if ((flags == NULL) != (fol == NULL))
@@ -2878,7 +2878,7 @@ static int read_rep_section(FILE *fd, garray_T *gap, short *first)
return SP_FORMERROR;
ftp->ft_to = read_cnt_string(fd, 1, &c);
if (c <= 0) {
- free(ftp->ft_from);
+ xfree(ftp->ft_from);
if (c < 0)
return c;
return SP_FORMERROR;
@@ -2973,7 +2973,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
// <saltolen> <salto>
smp->sm_to = read_cnt_string(fd, 1, &ccnt);
if (ccnt < 0) {
- free(smp->sm_lead);
+ xfree(smp->sm_lead);
return ccnt;
}
@@ -3136,7 +3136,7 @@ static int read_sofo_section(FILE *fd, slang_T *slang)
// <sofotolen> <sofoto>
to = read_cnt_string(fd, 2, &cnt);
if (cnt < 0) {
- free(from);
+ xfree(from);
return cnt;
}
@@ -3148,8 +3148,8 @@ static int read_sofo_section(FILE *fd, slang_T *slang)
else
res = 0;
- free(from);
- free(to);
+ xfree(from);
+ xfree(to);
return res;
}
@@ -3250,7 +3250,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
while (todo-- > 0) {
c = getc(fd); // <compflags>
if (c == EOF) {
- free(pat);
+ xfree(pat);
return SP_TRUNCERROR;
}
@@ -3281,7 +3281,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
// Copy flag to "sl_comprules", unless we run into a wildcard.
if (crp != NULL) {
if (c == '?' || c == '+' || c == '*') {
- free(slang->sl_comprules);
+ xfree(slang->sl_comprules);
slang->sl_comprules = NULL;
crp = NULL;
} else
@@ -3311,7 +3311,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
*crp = NUL;
slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT);
- free(pat);
+ xfree(pat);
if (slang->sl_compprog == NULL)
return SP_FORMERROR;
@@ -3961,7 +3961,7 @@ char_u *did_set_spelllang(win_T *wp)
}
theend:
- free(spl_copy);
+ xfree(spl_copy);
recursive = false;
redraw_win_later(wp, NOT_VALID);
return ret_msg;
@@ -3971,7 +3971,7 @@ theend:
static void clear_midword(win_T *wp)
{
memset(wp->w_s->b_spell_ismw, 0, 256);
- free(wp->w_s->b_spell_ismw_mb);
+ xfree(wp->w_s->b_spell_ismw_mb);
wp->w_s->b_spell_ismw_mb = NULL;
}
@@ -4000,7 +4000,7 @@ static void use_midword(slang_T *lp, win_T *wp)
// Append multi-byte chars to "b_spell_ismw_mb".
n = (int)STRLEN(wp->w_s->b_spell_ismw_mb);
bp = vim_strnsave(wp->w_s->b_spell_ismw_mb, n + l);
- free(wp->w_s->b_spell_ismw_mb);
+ xfree(wp->w_s->b_spell_ismw_mb);
wp->w_s->b_spell_ismw_mb = bp;
STRLCPY(bp + n, p, l + 1);
}
@@ -4124,7 +4124,7 @@ void spell_delete_wordlist(void)
os_remove((char *)int_wordlist);
int_wordlist_spl(fname);
os_remove((char *)fname);
- free(int_wordlist);
+ xfree(int_wordlist);
int_wordlist = NULL;
}
}
@@ -4147,9 +4147,9 @@ void spell_free_all(void)
spell_delete_wordlist();
- free(repl_to);
+ xfree(repl_to);
repl_to = NULL;
- free(repl_from);
+ xfree(repl_from);
repl_from = NULL;
}
@@ -4392,7 +4392,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
continue;
// Convert from "SET" to 'encoding' when needed.
- free(pc);
+ xfree(pc);
if (spin->si_conv.vc_type != CONV_NONE) {
pc = string_convert(&spin->si_conv, rline, NULL);
if (pc == NULL) {
@@ -5005,9 +5005,9 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
(void)set_spell_chartab(fol, low, upp);
}
- free(fol);
- free(low);
- free(upp);
+ xfree(fol);
+ xfree(low);
+ xfree(upp);
}
// Use compound specifications of the .aff file for the spell info.
@@ -5070,7 +5070,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
spin->si_midword = midword;
}
- free(pc);
+ xfree(pc);
fclose(fd);
return aff;
}
@@ -5344,7 +5344,7 @@ static void spell_free_aff(afffile_T *aff)
affheader_T *ah;
affentry_T *ae;
- free(aff->af_enc);
+ xfree(aff->af_enc);
// All this trouble to free the "ae_prog" items...
for (ht = &aff->af_pref;; ht = &aff->af_suff) {
@@ -5461,7 +5461,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
// Skip non-ASCII words when "spin->si_ascii" is true.
if (spin->si_ascii && has_non_ascii(w)) {
++non_ascii;
- free(pc);
+ xfree(pc);
continue;
}
@@ -5483,7 +5483,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
dw = getroom_save(spin, w);
if (dw == NULL) {
retval = FAIL;
- free(pc);
+ xfree(pc);
break;
}
@@ -5542,7 +5542,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
retval = FAIL;
}
- free(pc);
+ xfree(pc);
}
if (duplicate > 0)
@@ -5938,7 +5938,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
rline[l] = NUL;
// Convert from "/encoding={encoding}" to 'encoding' when needed.
- free(pc);
+ xfree(pc);
if (spin->si_conv.vc_type != CONV_NONE) {
pc = string_convert(&spin->si_conv, rline, NULL);
if (pc == NULL) {
@@ -5974,7 +5974,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
p_enc) == FAIL)
smsg((char_u *)_("Conversion in %s not supported: from %s to %s"),
fname, line, p_enc);
- free(enc);
+ xfree(enc);
spin->si_conv.vc_fail = true;
}
continue;
@@ -6054,7 +6054,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
did_word = true;
}
- free(pc);
+ xfree(pc);
fclose(fd);
if (spin->si_ascii && non_ascii > 0) {
@@ -6123,7 +6123,7 @@ static void free_blocks(sblock_T *bl)
while (bl != NULL) {
next = bl->sb_next;
- free(bl);
+ xfree(bl);
bl = next;
}
}
@@ -7167,7 +7167,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname)
sug_write(spin, fname);
theend:
- free(fname);
+ xfree(fname);
if (free_slang)
slang_free(slang);
free_blocks(spin->si_blocks);
@@ -7514,7 +7514,7 @@ static void close_spellbuf(buf_T *buf)
{
if (buf != NULL) {
ml_close(buf, TRUE);
- free(buf);
+ xfree(buf);
}
}
@@ -7737,8 +7737,8 @@ mkspell (
}
theend:
- free(fname);
- free(wfname);
+ xfree(fname);
+ xfree(wfname);
}
// Display a message for spell file processing when 'verbose' is set or using
@@ -7812,7 +7812,7 @@ spell_add_word (
break;
if (*spf == NUL) {
EMSGN(_("E765: 'spellfile' does not have %" PRId64 " entries"), idx);
- free(fnamebuf);
+ xfree(fnamebuf);
return;
}
}
@@ -7823,7 +7823,7 @@ spell_add_word (
buf = NULL;
if (buf != NULL && bufIsChanged(buf)) {
EMSG(_(e_bufloaded));
- free(fnamebuf);
+ xfree(fnamebuf);
return;
}
@@ -7908,7 +7908,7 @@ spell_add_word (
redraw_all_later(SOME_VALID);
}
- free(fnamebuf);
+ xfree(fnamebuf);
}
// Initialize 'spellfile' for the current buffer.
@@ -7977,7 +7977,7 @@ static void init_spellfile(void)
aspath = false;
}
- free(buf);
+ xfree(buf);
}
}
@@ -8464,9 +8464,9 @@ void spell_suggest(int count)
smsg((char_u *)_("Sorry, only %" PRId64 " suggestions"),
(int64_t)sug.su_ga.ga_len);
} else {
- free(repl_from);
+ xfree(repl_from);
repl_from = NULL;
- free(repl_to);
+ xfree(repl_to);
repl_to = NULL;
// When 'rightleft' is set the list is drawn right-left.
@@ -8638,7 +8638,7 @@ static bool check_need_cap(linenr_T lnum, colnr_T col)
}
}
- free(line_copy);
+ xfree(line_copy);
return need_cap;
}
@@ -8696,7 +8696,7 @@ void ex_spellrepall(exarg_T *eap)
p_ws = save_ws;
curwin->w_cursor = pos;
- free(frompat);
+ xfree(frompat);
if (sub_nsubs == 0)
EMSG2(_("E753: Not found: %s"), repl_from);
@@ -8849,7 +8849,7 @@ spell_find_suggest (
}
}
- free(sps_copy);
+ xfree(sps_copy);
if (do_combine)
// Combine the two list of suggestions. This must be done last,
@@ -9181,7 +9181,7 @@ static void tree_count_words(char_u *byts, idx_T *idxs)
// Free the info put in "*su" by spell_find_suggest().
static void spell_find_cleanup(suginfo_T *su)
{
-# define FREE_SUG_WORD(sug) free(sug->st_word)
+# define FREE_SUG_WORD(sug) xfree(sug->st_word)
// Free the suggestions.
GA_DEEP_CLEAR(&su->su_ga, suggest_T, FREE_SUG_WORD);
GA_DEEP_CLEAR(&su->su_sga, suggest_T, FREE_SUG_WORD);
@@ -10866,7 +10866,7 @@ static void score_combine(suginfo_T *su)
if (j == ga.ga_len)
stp[ga.ga_len++] = SUG(*gap, i);
else
- free(p);
+ xfree(p);
}
}
}
@@ -10877,7 +10877,7 @@ static void score_combine(suginfo_T *su)
// Truncate the list to the number of suggestions that will be displayed.
if (ga.ga_len > su->su_maxcount) {
for (int i = su->su_maxcount; i < ga.ga_len; ++i) {
- free(stp[i].st_word);
+ xfree(stp[i].st_word);
}
ga.ga_len = su->su_maxcount;
}
@@ -11004,7 +11004,7 @@ static void suggest_try_soundalike_finish(void)
todo = (int)slang->sl_sounddone.ht_used;
for (hi = slang->sl_sounddone.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi)) {
- free(HI2SFT(hi));
+ xfree(HI2SFT(hi));
--todo;
}
@@ -11328,7 +11328,7 @@ static void set_map_str(slang_T *lp, char_u *map)
// This should have been checked when generating the .spl
// file.
EMSG(_("E783: duplicate char in MAP entry"));
- free(b);
+ xfree(b);
}
} else
lp->sl_map_array[c] = headc;
@@ -11511,7 +11511,7 @@ check_suggestions (
(void)spell_check(curwin, longword, &attr, NULL, false);
if (attr != HLF_COUNT) {
// Remove this entry.
- free(stp[i].st_word);
+ xfree(stp[i].st_word);
--gap->ga_len;
if (i < gap->ga_len)
memmove(stp + i, stp + i + 1,
@@ -11608,7 +11608,7 @@ cleanup_suggestions (
// Truncate the list to the number of suggestions that will be displayed.
if (gap->ga_len > keep) {
for (int i = keep; i < gap->ga_len; ++i) {
- free(stp[i].st_word);
+ xfree(stp[i].st_word);
}
gap->ga_len = keep;
return stp[keep - 1].st_score;
@@ -12548,7 +12548,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword)
}
i = CNT(badlen - 1, goodlen - 1);
- free(cnt);
+ xfree(cnt);
return i;
}
@@ -12906,7 +12906,7 @@ void ex_spelldump(exarg_T *eap)
// enable spelling locally in the new window
set_option_value((char_u*)"spell", TRUE, (char_u*)"", OPT_LOCAL);
set_option_value((char_u*)"spl", dummy, spl, OPT_LOCAL);
- free(spl);
+ xfree(spl);
if (!bufempty() || !buf_valid(curbuf))
return;
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index dd10184d38..4e70f48860 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -269,7 +269,7 @@ char_u *strup_save(const char_u *orig)
memcpy(s, res, (size_t)(p - res));
STRCPY(s + (p - res) + newl, p + l);
p = s + (p - res);
- free(res);
+ xfree(res);
res = s;
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 7be7c26954..8c32e5f06a 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -959,7 +959,7 @@ static void syn_stack_free_block(synblock_T *block)
if (block->b_sst_array != NULL) {
for (p = block->b_sst_first; p != NULL; p = p->sst_next)
clear_syn_state(p);
- free(block->b_sst_array);
+ xfree(block->b_sst_array);
block->b_sst_array = NULL;
block->b_sst_len = 0;
}
@@ -1044,7 +1044,7 @@ static void syn_stack_alloc(void)
to->sst_next = to + 1;
(sstp + len - 1)->sst_next = NULL;
- free(syn_block->b_sst_array);
+ xfree(syn_block->b_sst_array);
syn_block->b_sst_array = sstp;
syn_block->b_sst_len = len;
}
@@ -3054,7 +3054,7 @@ void syntax_clear(synblock_T *block)
vim_regfree(block->b_syn_linecont_prog);
block->b_syn_linecont_prog = NULL;
- free(block->b_syn_linecont_pat);
+ xfree(block->b_syn_linecont_pat);
block->b_syn_linecont_pat = NULL;
block->b_syn_folditems = 0;
@@ -3073,7 +3073,7 @@ void reset_synblock(win_T *wp)
{
if (wp->w_s != &wp->w_buffer->b_s) {
syntax_clear(wp->w_s);
- free(wp->w_s);
+ xfree(wp->w_s);
wp->w_s = &wp->w_buffer->b_s;
}
}
@@ -3097,7 +3097,7 @@ static void syntax_sync_clear(void)
vim_regfree(curwin->w_s->b_syn_linecont_prog);
curwin->w_s->b_syn_linecont_prog = NULL;
- free(curwin->w_s->b_syn_linecont_pat);
+ xfree(curwin->w_s->b_syn_linecont_pat);
curwin->w_s->b_syn_linecont_pat = NULL;
syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */
@@ -3125,13 +3125,13 @@ static void syn_remove_pattern(synblock_T *block, int idx)
*/
static void syn_clear_pattern(synblock_T *block, int i)
{
- free(SYN_ITEMS(block)[i].sp_pattern);
+ xfree(SYN_ITEMS(block)[i].sp_pattern);
vim_regfree(SYN_ITEMS(block)[i].sp_prog);
/* Only free sp_cont_list and sp_next_list of first start pattern */
if (i == 0 || SYN_ITEMS(block)[i - 1].sp_type != SPTYPE_START) {
- free(SYN_ITEMS(block)[i].sp_cont_list);
- free(SYN_ITEMS(block)[i].sp_next_list);
- free(SYN_ITEMS(block)[i].sp_syn.cont_in_list);
+ xfree(SYN_ITEMS(block)[i].sp_cont_list);
+ xfree(SYN_ITEMS(block)[i].sp_next_list);
+ xfree(SYN_ITEMS(block)[i].sp_syn.cont_in_list);
}
}
@@ -3140,9 +3140,9 @@ static void syn_clear_pattern(synblock_T *block, int i)
*/
static void syn_clear_cluster(synblock_T *block, int i)
{
- free(SYN_CLSTR(block)[i].scl_name);
- free(SYN_CLSTR(block)[i].scl_name_u);
- free(SYN_CLSTR(block)[i].scl_list);
+ xfree(SYN_CLSTR(block)[i].scl_name);
+ xfree(SYN_CLSTR(block)[i].scl_name_u);
+ xfree(SYN_CLSTR(block)[i].scl_list);
}
/*
@@ -3198,7 +3198,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
*/
short scl_id = id - SYNID_CLUSTER;
- free(SYN_CLSTR(curwin->w_s)[scl_id].scl_list);
+ xfree(SYN_CLSTR(curwin->w_s)[scl_id].scl_list);
SYN_CLSTR(curwin->w_s)[scl_id].scl_list = NULL;
}
} else {
@@ -3760,9 +3760,9 @@ static void syn_clear_keyword(int id, hashtab_T *ht)
hi->hi_key = KE2HIKEY(kp_next);
} else
kp_prev->ke_next = kp_next;
- free(kp->next_list);
- free(kp->k_syn.cont_in_list);
- free(kp);
+ xfree(kp->next_list);
+ xfree(kp->k_syn.cont_in_list);
+ xfree(kp);
kp = kp_next;
} else {
kp_prev = kp;
@@ -3789,9 +3789,9 @@ static void clear_keywtab(hashtab_T *ht)
--todo;
for (kp = HI2KE(hi); kp != NULL; kp = kp_next) {
kp_next = kp->ke_next;
- free(kp->next_list);
- free(kp->k_syn.cont_in_list);
- free(kp);
+ xfree(kp->next_list);
+ xfree(kp->k_syn.cont_in_list);
+ xfree(kp);
}
}
}
@@ -4011,12 +4011,12 @@ get_syn_options (
}
if (i < 0) {
EMSG2(_("E394: Didn't find region item for %s"), gname);
- free(gname);
+ xfree(gname);
return NULL;
}
}
- free(gname);
+ xfree(gname);
arg = skipwhite(arg);
} else if (flagtab[fidx].flags == HL_FOLD
&& foldmethodIsSyntax(curwin))
@@ -4208,9 +4208,9 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
}
}
- free(keyword_copy);
- free(syn_opt_arg.cont_in_list);
- free(syn_opt_arg.next_list);
+ xfree(keyword_copy);
+ xfree(syn_opt_arg.cont_in_list);
+ xfree(syn_opt_arg.next_list);
}
if (rest != NULL)
@@ -4311,10 +4311,10 @@ syn_cmd_match (
* Something failed, free the allocated memory.
*/
vim_regfree(item.sp_prog);
- free(item.sp_pattern);
- free(syn_opt_arg.cont_list);
- free(syn_opt_arg.cont_in_list);
- free(syn_opt_arg.next_list);
+ xfree(item.sp_pattern);
+ xfree(syn_opt_arg.cont_list);
+ xfree(syn_opt_arg.cont_in_list);
+ xfree(syn_opt_arg.next_list);
if (rest == NULL)
EMSG2(_(e_invarg2), arg);
@@ -4388,7 +4388,7 @@ syn_cmd_region (
key_end = rest;
while (*key_end && !vim_iswhite(*key_end) && *key_end != '=')
++key_end;
- free(key);
+ xfree(key);
key = vim_strnsave_up(rest, (int)(key_end - rest));
if (STRCMP(key, "MATCHGROUP") == 0)
item = ITEM_MATCHGROUP;
@@ -4456,7 +4456,7 @@ syn_cmd_region (
++pat_count;
}
}
- free(key);
+ xfree(key);
if (illegal || not_enough)
rest = NULL;
@@ -4530,17 +4530,17 @@ syn_cmd_region (
for (ppp = pat_ptrs[item]; ppp != NULL; ppp = ppp_next) {
if (!success) {
vim_regfree(ppp->pp_synp->sp_prog);
- free(ppp->pp_synp->sp_pattern);
+ xfree(ppp->pp_synp->sp_pattern);
}
- free(ppp->pp_synp);
+ xfree(ppp->pp_synp);
ppp_next = ppp->pp_next;
- free(ppp);
+ xfree(ppp);
}
if (!success) {
- free(syn_opt_arg.cont_list);
- free(syn_opt_arg.cont_in_list);
- free(syn_opt_arg.next_list);
+ xfree(syn_opt_arg.cont_list);
+ xfree(syn_opt_arg.cont_in_list);
+ xfree(syn_opt_arg.next_list);
if (not_enough)
EMSG2(_("E399: Not enough arguments: syntax region %s"), arg);
else if (illegal || rest == NULL)
@@ -4580,11 +4580,11 @@ static void syn_combine_list(short **clstr1, short **clstr2, int list_op)
return;
if (*clstr1 == NULL || list_op == CLUSTER_REPLACE) {
if (list_op == CLUSTER_REPLACE)
- free(*clstr1);
+ xfree(*clstr1);
if (list_op == CLUSTER_REPLACE || list_op == CLUSTER_ADD)
*clstr1 = *clstr2;
else
- free(*clstr2);
+ xfree(*clstr2);
return;
}
@@ -4668,8 +4668,8 @@ static void syn_combine_list(short **clstr1, short **clstr2, int list_op)
/*
* Finally, put the new list in place.
*/
- free(*clstr1);
- free(*clstr2);
+ xfree(*clstr1);
+ xfree(*clstr2);
*clstr1 = clstr;
}
@@ -4688,7 +4688,7 @@ static int syn_scl_name2id(char_u *name)
break;
}
}
- free(name_u);
+ xfree(name_u);
return i < 0 ? 0 : i + SYNID_CLUSTER;
}
@@ -4699,7 +4699,7 @@ static int syn_scl_namen2id(char_u *linep, int len)
{
char_u *name = vim_strnsave(linep, len);
int id = syn_scl_name2id(name);
- free(name);
+ xfree(name);
return id;
}
@@ -4721,7 +4721,7 @@ static int syn_check_cluster(char_u *pp, int len)
if (id == 0) /* doesn't exist yet */
id = syn_add_cluster(name);
else
- free(name);
+ xfree(name);
return id;
}
@@ -4743,7 +4743,7 @@ static int syn_add_cluster(char_u *name)
int len = curwin->w_s->b_syn_clusters.ga_len;
if (len >= MAX_CLUSTER_ID) {
EMSG((char_u *)_("E848: Too many syntax clusters"));
- free(name);
+ xfree(name);
return 0;
}
@@ -4945,7 +4945,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
while (!ends_excmd(*arg_start)) {
arg_end = skiptowhite(arg_start);
next_arg = skipwhite(arg_end);
- free(key);
+ xfree(key);
key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start));
if (STRCMP(key, "CCOMMENT") == 0) {
if (!eap->skip)
@@ -5013,7 +5013,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
syn_clear_time(&curwin->w_s->b_syn_linecont_time);
if (curwin->w_s->b_syn_linecont_prog == NULL) {
- free(curwin->w_s->b_syn_linecont_pat);
+ xfree(curwin->w_s->b_syn_linecont_pat);
curwin->w_s->b_syn_linecont_pat = NULL;
finished = TRUE;
break;
@@ -5035,7 +5035,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
}
arg_start = next_arg;
}
- free(key);
+ xfree(key);
if (illegal)
EMSG2(_("E404: Illegal arguments: %s"), arg_start);
else if (!finished) {
@@ -5109,13 +5109,13 @@ get_id_list (
if (TOUPPER_ASC(**arg) != 'C') {
EMSG2(_("E407: %s not allowed here"), name + 1);
failed = TRUE;
- free(name);
+ xfree(name);
break;
}
if (count != 0) {
EMSG2(_("E408: %s must be first in contains list"), name + 1);
failed = TRUE;
- free(name);
+ xfree(name);
break;
}
if (name[1] == 'A')
@@ -5142,7 +5142,7 @@ get_id_list (
regmatch.regprog = vim_regcomp(name, RE_MAGIC);
if (regmatch.regprog == NULL) {
failed = TRUE;
- free(name);
+ xfree(name);
break;
}
@@ -5156,7 +5156,7 @@ get_id_list (
* "contains=a.*b,axb".
* Go back to first round */
if (count >= total_count) {
- free(retval);
+ xfree(retval);
round = 1;
} else
retval[count] = i + 1;
@@ -5168,7 +5168,7 @@ get_id_list (
vim_regfree(regmatch.regprog);
}
}
- free(name);
+ xfree(name);
if (id == 0) {
EMSG2(_("E409: Unknown group name: %s"), p);
failed = TRUE;
@@ -5178,7 +5178,7 @@ get_id_list (
if (round == 2) {
/* Got more items than expected, go back to first round */
if (count >= total_count) {
- free(retval);
+ xfree(retval);
round = 1;
} else
retval[count] = id;
@@ -5201,14 +5201,14 @@ get_id_list (
*arg = p;
if (failed || retval == NULL) {
- free(retval);
+ xfree(retval);
return FAIL;
}
if (*list == NULL)
*list = retval;
else
- free(retval); /* list already found, don't overwrite it */
+ xfree(retval); /* list already found, don't overwrite it */
return OK;
}
@@ -5387,7 +5387,7 @@ void ex_syntax(exarg_T *eap)
break;
}
}
- free(subcmd_name);
+ xfree(subcmd_name);
if (eap->skip)
--emsg_skip;
}
@@ -5427,7 +5427,7 @@ void ex_ownsyntax(exarg_T *eap)
do_unlet((char_u *)"b:current_syntax", TRUE);
else {
set_internal_string_var((char_u *)"b:current_syntax", old_value);
- free(old_value);
+ xfree(old_value);
}
}
@@ -5862,7 +5862,7 @@ init_highlight (
// p invalid, so copy it.
char_u *copy_p = vim_strsave(p);
bool okay = load_colors(copy_p);
- free(copy_p);
+ xfree(copy_p);
if (okay) {
return;
}
@@ -5943,7 +5943,7 @@ int load_colors(char_u *name)
buf = xmalloc(STRLEN(name) + 12);
sprintf((char *)buf, "colors/%s.vim", name);
retval = source_runtime(buf, FALSE);
- free(buf);
+ xfree(buf);
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf);
recursive = FALSE;
@@ -6145,7 +6145,7 @@ do_highlight (
*/
while (*linep && !vim_iswhite(*linep) && *linep != '=')
++linep;
- free(key);
+ xfree(key);
key = vim_strnsave_up(key_start, (int)(linep - key_start));
linep = skipwhite(linep);
@@ -6189,7 +6189,7 @@ do_highlight (
error = TRUE;
break;
}
- free(arg);
+ xfree(arg);
arg = vim_strnsave(arg_start, (int)(linep - arg_start));
if (*linep == '\'')
@@ -6394,7 +6394,7 @@ do_highlight (
if (!init)
HL_TABLE()[idx].sg_set |= SG_GUI;
- free(HL_TABLE()[idx].sg_rgb_fg_name);
+ xfree(HL_TABLE()[idx].sg_rgb_fg_name);
if (STRCMP(arg, "NONE")) {
HL_TABLE()[idx].sg_rgb_fg_name = (uint8_t *)xstrdup((char *)arg);
HL_TABLE()[idx].sg_rgb_fg = name_to_color(arg);
@@ -6412,7 +6412,7 @@ do_highlight (
if (!init)
HL_TABLE()[idx].sg_set |= SG_GUI;
- free(HL_TABLE()[idx].sg_rgb_bg_name);
+ xfree(HL_TABLE()[idx].sg_rgb_bg_name);
if (STRCMP(arg, "NONE") != 0) {
HL_TABLE()[idx].sg_rgb_bg_name = (uint8_t *)xstrdup((char *)arg);
HL_TABLE()[idx].sg_rgb_bg = name_to_color(arg);
@@ -6462,8 +6462,8 @@ do_highlight (
HL_TABLE()[idx].sg_scriptID = current_SID;
redraw_all_later(NOT_VALID);
}
- free(key);
- free(arg);
+ xfree(key);
+ xfree(arg);
/* Only call highlight_changed() once, after sourcing a syntax file */
need_highlight_changed = TRUE;
@@ -6474,8 +6474,8 @@ void free_highlight(void)
{
for (int i = 0; i < highlight_ga.ga_len; ++i) {
highlight_clear(i);
- free(HL_TABLE()[i].sg_name);
- free(HL_TABLE()[i].sg_name_u);
+ xfree(HL_TABLE()[i].sg_name);
+ xfree(HL_TABLE()[i].sg_name_u);
}
ga_clear(&highlight_ga);
}
@@ -6522,9 +6522,9 @@ static void highlight_clear(int idx)
HL_TABLE()[idx].sg_gui = 0;
HL_TABLE()[idx].sg_rgb_fg = -1;
HL_TABLE()[idx].sg_rgb_bg = -1;
- free(HL_TABLE()[idx].sg_rgb_fg_name);
+ xfree(HL_TABLE()[idx].sg_rgb_fg_name);
HL_TABLE()[idx].sg_rgb_fg_name = NULL;
- free(HL_TABLE()[idx].sg_rgb_bg_name);
+ xfree(HL_TABLE()[idx].sg_rgb_bg_name);
HL_TABLE()[idx].sg_rgb_bg_name = NULL;
/* Clear the script ID only when there is no link, since that is not
* cleared. */
@@ -6959,7 +6959,7 @@ int syn_namen2id(char_u *linep, int len)
{
char_u *name = vim_strnsave(linep, len);
int id = syn_name2id(name);
- free(name);
+ xfree(name);
return id;
}
@@ -6981,7 +6981,7 @@ int syn_check_group(char_u *pp, int len)
if (id == 0) /* doesn't exist yet */
id = syn_add_group(name);
else
- free(name);
+ xfree(name);
return id;
}
@@ -6998,7 +6998,7 @@ static int syn_add_group(char_u *name)
for (p = name; *p != NUL; ++p) {
if (!vim_isprintc(*p)) {
EMSG(_("E669: Unprintable character in group name"));
- free(name);
+ xfree(name);
return 0;
} else if (!ASCII_ISALNUM(*p) && *p != '_') {
/* This is an error, but since there previously was no check only
@@ -7019,7 +7019,7 @@ static int syn_add_group(char_u *name)
if (highlight_ga.ga_len >= MAX_HL_ID) {
EMSG(_("E849: Too many highlight and syntax groups"));
- free(name);
+ xfree(name);
return 0;
}
@@ -7039,8 +7039,8 @@ static int syn_add_group(char_u *name)
static void syn_unadd_group(void)
{
--highlight_ga.ga_len;
- free(HL_TABLE()[highlight_ga.ga_len].sg_name);
- free(HL_TABLE()[highlight_ga.ga_len].sg_name_u);
+ xfree(HL_TABLE()[highlight_ga.ga_len].sg_name);
+ xfree(HL_TABLE()[highlight_ga.ga_len].sg_name_u);
}
/*
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 1f6b42d9cf..75b0698bd3 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -246,7 +246,7 @@ do_tag (
cur_match = ptag_entry.cur_match;
cur_fnum = ptag_entry.cur_fnum;
} else {
- free(ptag_entry.tagname);
+ xfree(ptag_entry.tagname);
ptag_entry.tagname = vim_strsave(tag);
}
} else {
@@ -255,12 +255,12 @@ do_tag (
* stack entries above it.
*/
while (tagstackidx < tagstacklen)
- free(tagstack[--tagstacklen].tagname);
+ xfree(tagstack[--tagstacklen].tagname);
/* if the tagstack is full: remove oldest entry */
if (++tagstacklen > TAGSTACKSIZE) {
tagstacklen = TAGSTACKSIZE;
- free(tagstack[0].tagname);
+ xfree(tagstack[0].tagname);
for (i = 1; i < tagstacklen; ++i)
tagstack[i - 1] = tagstack[i];
--tagstackidx;
@@ -450,7 +450,7 @@ do_tag (
|| (cur_match >= num_matches && max_num_matches != MAXCOL)
|| other_name) {
if (other_name) {
- free(tagmatchname);
+ xfree(tagmatchname);
tagmatchname = vim_strsave(name);
}
@@ -569,7 +569,7 @@ do_tag (
* it and put "..." in the middle */
p = tag_full_fname(&tagp);
msg_puts_long_attr(p, hl_attr(HLF_D));
- free(p);
+ xfree(p);
if (msg_col > 0)
msg_putchar('\n');
@@ -709,7 +709,7 @@ do_tag (
/* Save the tag file name */
p = tag_full_fname(&tagp);
STRLCPY(fname, p, MAXPATHL + 1);
- free(p);
+ xfree(p);
/*
* Get the line number or the search pattern used to locate
@@ -804,8 +804,8 @@ do_tag (
set_errorlist(curwin, list, ' ', IObuff);
list_free(list, TRUE);
- free(fname);
- free(cmd);
+ xfree(fname);
+ xfree(cmd);
cur_match = 0; /* Jump to the first tag */
}
@@ -941,7 +941,7 @@ end_do_tag:
*/
void tag_freematch(void)
{
- free(tagmatchname);
+ xfree(tagmatchname);
tagmatchname = NULL;
}
@@ -983,7 +983,7 @@ void do_tags(exarg_T *eap)
msg_outtrans(IObuff);
msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum
? hl_attr(HLF_D) : 0);
- free(name);
+ xfree(name);
}
ui_flush(); /* show one line at a time */
}
@@ -1411,12 +1411,12 @@ line_read_in:
/* Copy or swap lbuf and conv_line. */
len = (int)STRLEN(conv_line) + 1;
if (len > lbuf_size) {
- free(lbuf);
+ xfree(lbuf);
lbuf = conv_line;
lbuf_size = len;
} else {
STRCPY(lbuf, conv_line);
- free(conv_line);
+ xfree(conv_line);
}
}
}
@@ -1873,7 +1873,7 @@ parse_line:
[ga_match[mtt].ga_len++] = mfp;
++match_count;
} else
- free(mfp);
+ xfree(mfp);
}
}
}
@@ -1932,9 +1932,9 @@ parse_line:
}
findtag_end:
- free(lbuf);
+ xfree(lbuf);
vim_regfree(orgpat.regmatch.regprog);
- free(tag_fname);
+ xfree(tag_fname);
/*
* Move the matches from the ga_match[] arrays into one list of
@@ -1952,7 +1952,7 @@ findtag_end:
for (int i = 0; i < ga_match[mtt].ga_len; ++i) {
mfp = ((struct match_found **)(ga_match[mtt].ga_data))[i];
if (matches == NULL)
- free(mfp);
+ xfree(mfp);
else {
/* To avoid allocating memory again we turn the struct
* match_found into a string. For help the priority was not
@@ -1969,7 +1969,7 @@ findtag_end:
*num_matches = match_count;
curbuf->b_help = help_save;
- free(saved_pat);
+ xfree(saved_pat);
return retval;
}
@@ -1993,7 +1993,7 @@ void free_tag_stuff(void)
tag_freematch();
if (ptag_entry.tagname) {
- free(ptag_entry.tagname);
+ xfree(ptag_entry.tagname);
ptag_entry.tagname = NULL;
}
}
@@ -2102,7 +2102,7 @@ get_tagfname (
}
STRCPY(buf, fname);
- free(fname);
+ xfree(fname);
return OK;
}
@@ -2111,7 +2111,7 @@ get_tagfname (
*/
void tagname_free(tagname_T *tnp)
{
- free(tnp->tn_tags);
+ xfree(tnp->tn_tags);
vim_findfile_cleanup(tnp->tn_search_ctx);
tnp->tn_search_ctx = NULL;
ga_clear_strings(&tag_fnames);
@@ -2362,7 +2362,7 @@ jumpto_tag (
&& !has_autocmd(EVENT_BUFREADCMD, fname, NULL)
) {
retval = NOTAGFILE;
- free(nofile_fname);
+ xfree(nofile_fname);
nofile_fname = vim_strsave(fname);
goto erret;
}
@@ -2565,9 +2565,9 @@ erret:
g_do_tagpreview = 0; /* For next time */
if (tagp.fname_end != NULL)
*tagp.fname_end = csave;
- free(pbuf);
- free(tofree_fname);
- free(full_fname);
+ xfree(pbuf);
+ xfree(tofree_fname);
+ xfree(full_fname);
return retval;
}
@@ -2611,7 +2611,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
} else
retval = vim_strsave(fname);
- free(expanded_fname);
+ xfree(expanded_fname);
return retval;
}
@@ -2635,7 +2635,7 @@ static int test_for_current(char_u *fname, char_u *fname_end, char_u *tag_fname,
}
fullname = expand_tag_fname(fname, tag_fname, TRUE);
retval = (path_full_compare(fullname, buf_ffname, TRUE) & kEqualFiles);
- free(fullname);
+ xfree(fullname);
*fname_end = c;
}
@@ -2761,7 +2761,7 @@ add_tag_field (
}
buf[len] = NUL;
retval = dict_add_nr_str(dict, field_name, 0L, buf);
- free(buf);
+ xfree(buf);
return retval;
}
@@ -2804,7 +2804,7 @@ int get_tags(list_T *list, char_u *pat)
|| dict_add_nr_str(dict, "static", is_static, NULL) == FAIL)
ret = FAIL;
- free(full_fname);
+ xfree(full_fname);
if (tp.command_end != NULL) {
for (p = tp.command_end + 3;
@@ -2844,9 +2844,9 @@ int get_tags(list_T *list, char_u *pat)
}
}
- free(matches[i]);
+ xfree(matches[i]);
}
- free(matches);
+ xfree(matches);
}
return ret;
}
diff --git a/src/nvim/tempfile.c b/src/nvim/tempfile.c
index 0750be0ab9..1b51b226db 100644
--- a/src/nvim/tempfile.c
+++ b/src/nvim/tempfile.c
@@ -77,7 +77,7 @@ void vim_deltempdir(void)
path_tail(NameBuff)[-1] = NUL;
os_rmdir((char *)NameBuff);
- free(vim_tempdir);
+ xfree(vim_tempdir);
vim_tempdir = NULL;
}
}
@@ -109,7 +109,7 @@ static bool vim_settempdir(char_u *tempdir)
vim_FullName(tempdir, buf, MAXPATHL, false);
add_pathsep(buf);
vim_tempdir = vim_strsave(buf);
- free(buf);
+ xfree(buf);
return true;
}
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index ea0cc88e58..8ee47b2642 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -243,7 +243,7 @@ Terminal *terminal_open(TerminalOptions opts)
char *name = get_config_string(rv, var);
if (name) {
color_val = name_to_color((uint8_t *)name);
- free(name);
+ xfree(name);
if (color_val != -1) {
rv->colors[i] = color_val;
@@ -424,11 +424,11 @@ void terminal_destroy(Terminal *term)
term->buf = NULL;
pmap_del(ptr_t)(invalidated_terminals, term);
for (size_t i = 0 ; i < term->sb_current; i++) {
- free(term->sb_buffer[i]);
+ xfree(term->sb_buffer[i]);
}
- free(term->sb_buffer);
+ xfree(term->sb_buffer);
vterm_free(term->vt);
- free(term);
+ xfree(term);
}
void terminal_send(Terminal *term, char *data, size_t size)
@@ -603,7 +603,7 @@ static int term_sb_push(int cols, const VTermScreenCell *cells, void *data)
// Recycle old row if it's the right size
sbrow = term->sb_buffer[term->sb_current - 1];
} else {
- free(term->sb_buffer[term->sb_current - 1]);
+ xfree(term->sb_buffer[term->sb_current - 1]);
}
memmove(term->sb_buffer + 1, term->sb_buffer,
@@ -664,7 +664,7 @@ static int term_sb_pop(int cols, VTermScreenCell *cells, void *data)
cells[col].chars[0] = 0;
cells[col].width = 1;
}
- free(sbrow);
+ xfree(sbrow);
pmap_put(ptr_t)(invalidated_terminals, term, NULL);
return 1;
diff --git a/src/nvim/tui/term_input.inl b/src/nvim/tui/term_input.inl
index c1ccc863de..ccc47080b8 100644
--- a/src/nvim/tui/term_input.inl
+++ b/src/nvim/tui/term_input.inl
@@ -296,5 +296,5 @@ static void term_input_destroy(TermInput *input)
uv_close((uv_handle_t *)&input->timer_handle, NULL);
termkey_destroy(input->tk);
event_poll(0); // Run once to remove references to input/timer handles
- free(input);
+ xfree(input);
}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 6d23c2cf74..763a7c0e6d 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -190,12 +190,12 @@ static void tui_stop(UI *ui)
if (uv_loop_close(data->write_loop)) {
abort();
}
- free(data->write_loop);
+ xfree(data->write_loop);
unibi_destroy(data->ut);
destroy_screen(data);
- free(data);
+ xfree(data);
ui_detach(ui);
- free(ui);
+ xfree(ui);
}
static void try_resize(Event ev)
@@ -851,8 +851,8 @@ static void destroy_screen(TUIData *data)
{
if (data->screen) {
for (int i = 0; i < data->old_height; i++) {
- free(data->screen[i]);
+ xfree(data->screen[i]);
}
- free(data->screen);
+ xfree(data->screen);
}
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 4a721a0884..1377282088 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -686,11 +686,11 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
(!reading || os_file_exists(undo_file_name))) {
break;
}
- free(undo_file_name);
+ xfree(undo_file_name);
undo_file_name = NULL;
}
- free(munged_name);
+ xfree(munged_name);
return undo_file_name;
}
@@ -710,7 +710,7 @@ static void u_free_uhp(u_header_T *uhp)
u_freeentry(uep, uep->ue_size);
uep = nuep;
}
- free(uhp);
+ xfree(uhp);
}
/// Writes the header.
@@ -823,7 +823,7 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi, char_u *file_name)
uhp->uh_seq = undo_read_4c(bi);
if (uhp->uh_seq <= 0) {
corruption_error("uh_seq", file_name);
- free(uhp);
+ xfree(uhp);
return NULL;
}
unserialize_pos(bi, &uhp->uh_cursor);
@@ -1204,7 +1204,7 @@ write_error:
theend:
if (file_name != name)
- free(file_name);
+ xfree(file_name);
}
/// Loads the undo tree from an undo file.
@@ -1470,7 +1470,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
curbuf->b_u_save_nr_cur = last_save_nr;
curbuf->b_u_synced = true;
- free(uhp_table);
+ xfree(uhp_table);
#ifdef U_DEBUG
for (int i = 0; i < num_head; i++) {
@@ -1478,7 +1478,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
EMSGN("uhp_table entry %" PRId64 " not used, leaking memory", i);
}
}
- free(uhp_table_used);
+ xfree(uhp_table_used);
u_check(TRUE);
#endif
@@ -1488,13 +1488,13 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
goto theend;
error:
- free(line_ptr);
+ xfree(line_ptr);
if (uhp_table != NULL) {
for (long i = 0; i < num_read_uhps; i++)
if (uhp_table[i] != NULL) {
u_free_uhp(uhp_table[i]);
}
- free(uhp_table);
+ xfree(uhp_table);
}
theend:
@@ -1502,7 +1502,7 @@ theend:
fclose(fp);
}
if (file_name != name) {
- free(file_name);
+ xfree(file_name);
}
}
@@ -1579,7 +1579,7 @@ static uint8_t *undo_read_string(bufinfo_T *bi, size_t len)
{
uint8_t *ptr = xmallocz(len);
if (len > 0 && !undo_read(bi, ptr, len)) {
- free(ptr);
+ xfree(ptr);
return NULL;
}
return ptr;
@@ -2107,9 +2107,9 @@ static void u_undoredo(int undo)
ml_replace((linenr_T)1, uep->ue_array[i], TRUE);
else
ml_append(lnum, uep->ue_array[i], (colnr_T)0, FALSE);
- free(uep->ue_array[i]);
+ xfree(uep->ue_array[i]);
}
- free((char_u *)uep->ue_array);
+ xfree((char_u *)uep->ue_array);
}
/* adjust marks */
@@ -2668,7 +2668,7 @@ u_freeentries (
#ifdef U_DEBUG
uhp->uh_magic = 0;
#endif
- free((char_u *)uhp);
+ xfree((char_u *)uhp);
--buf->b_u_numhead;
}
@@ -2678,12 +2678,12 @@ u_freeentries (
static void u_freeentry(u_entry_T *uep, long n)
{
while (n > 0)
- free(uep->ue_array[--n]);
- free((char_u *)uep->ue_array);
+ xfree(uep->ue_array[--n]);
+ xfree((char_u *)uep->ue_array);
#ifdef U_DEBUG
uep->ue_magic = 0;
#endif
- free((char_u *)uep);
+ xfree((char_u *)uep);
}
/*
@@ -2723,7 +2723,7 @@ void u_saveline(linenr_T lnum)
void u_clearline(void)
{
if (curbuf->b_u_line_ptr != NULL) {
- free(curbuf->b_u_line_ptr);
+ xfree(curbuf->b_u_line_ptr);
curbuf->b_u_line_ptr = NULL;
curbuf->b_u_line_lnum = 0;
}
@@ -2756,7 +2756,7 @@ void u_undoline(void)
oldp = u_save_line(curbuf->b_u_line_lnum);
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, TRUE);
changed_bytes(curbuf->b_u_line_lnum, 0);
- free(curbuf->b_u_line_ptr);
+ xfree(curbuf->b_u_line_ptr);
curbuf->b_u_line_ptr = oldp;
t = curbuf->b_u_line_colnr;
@@ -2777,7 +2777,7 @@ void u_blockfree(buf_T *buf)
u_freeheader(buf, buf->b_u_oldhead, NULL);
assert(buf->b_u_oldhead != previous_oldhead);
}
- free(buf->b_u_line_ptr);
+ xfree(buf->b_u_line_ptr);
}
/*
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9c56cc5b82..caa7ecc041 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -401,7 +401,7 @@ wingotofile:
beginline(BL_SOL | BL_FIX);
}
}
- free(ptr);
+ xfree(ptr);
}
break;
@@ -2065,7 +2065,7 @@ win_free_mem (
/* Remove the window and its frame from the tree of frames. */
frp = win->w_frame;
wp = winframe_remove(win, dirp, tp);
- free(frp);
+ xfree(frp);
win_free(win, tp);
/* When deleting the current window of another tab page select a new
@@ -2209,7 +2209,7 @@ winframe_remove (
if (frp2->fr_win != NULL)
frp2->fr_win->w_frame = frp2->fr_parent;
frp = frp2->fr_parent;
- free(frp2);
+ xfree(frp2);
frp2 = frp->fr_parent;
if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) {
@@ -2230,7 +2230,7 @@ winframe_remove (
break;
}
}
- free(frp);
+ xfree(frp);
}
}
@@ -2914,7 +2914,7 @@ void free_tabpage(tabpage_T *tp)
- free(tp);
+ xfree(tp);
}
/*
@@ -2934,7 +2934,7 @@ int win_new_tabpage(int after)
/* Remember the current windows in this Tab page. */
if (leave_tabpage(curbuf, TRUE) == FAIL) {
- free(newtp);
+ xfree(newtp);
return FAIL;
}
curtab = newtp;
@@ -3528,7 +3528,7 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri
/* Window doesn't have a local directory and we are not in the global
* directory: Change to the global directory. */
ignored = os_chdir((char *)globaldir);
- free(globaldir);
+ xfree(globaldir);
globaldir = NULL;
shorten_fnames(TRUE);
}
@@ -3702,9 +3702,9 @@ win_free (
win_free_lsize(wp);
for (i = 0; i < wp->w_tagstacklen; ++i)
- free(wp->w_tagstack[i].tagname);
+ xfree(wp->w_tagstack[i].tagname);
- free(wp->w_localdir);
+ xfree(wp->w_localdir);
/* Remove the window from the b_wininfo lists, it may happen that the
* freed memory is re-used for another window. */
@@ -3721,7 +3721,7 @@ win_free (
qf_free_all(wp);
- free(wp->w_p_cc_cols);
+ xfree(wp->w_p_cc_cols);
if (wp != aucmd_win)
win_remove(wp, tp);
@@ -3729,7 +3729,7 @@ win_free (
wp->w_next = au_pending_free_win;
au_pending_free_win = wp;
} else {
- free(wp);
+ xfree(wp);
}
unblock_autocmds();
@@ -3839,7 +3839,7 @@ void win_free_lsize(win_T *wp)
{
// TODO: why would wp be NULL here?
if (wp != NULL) {
- free(wp->w_lines);
+ xfree(wp->w_lines);
wp->w_lines = NULL;
}
}
@@ -5136,7 +5136,7 @@ static void clear_snapshot_rec(frame_T *fr)
if (fr != NULL) {
clear_snapshot_rec(fr->fr_next);
clear_snapshot_rec(fr->fr_child);
- free(fr);
+ xfree(fr);
}
}
@@ -5472,7 +5472,7 @@ int match_add(win_T *wp, char_u *grp, char_u *pat, int prio, int id, list_T *pos
return id;
fail:
- free(m);
+ xfree(m);
return -1;
}
@@ -5507,7 +5507,7 @@ int match_delete(win_T *wp, int id, int perr)
else
prev->next = cur->next;
vim_regfree(cur->match.regprog);
- free(cur->pattern);
+ xfree(cur->pattern);
if (cur->pos.toplnum != 0) {
if (wp->w_buffer->b_mod_set) {
if (wp->w_buffer->b_mod_top > cur->pos.toplnum) {
@@ -5524,7 +5524,7 @@ int match_delete(win_T *wp, int id, int perr)
}
rtype = VALID;
}
- free(cur);
+ xfree(cur);
redraw_later(rtype);
return 0;
}
@@ -5539,8 +5539,8 @@ void clear_matches(win_T *wp)
while (wp->w_match_head != NULL) {
m = wp->w_match_head->next;
vim_regfree(wp->w_match_head->match.regprog);
- free(wp->w_match_head->pattern);
- free(wp->w_match_head);
+ xfree(wp->w_match_head->pattern);
+ xfree(wp->w_match_head);
wp->w_match_head = m;
}
redraw_later(SOME_VALID);