memory: Add free wrapper and refactor project to use it

We already use wrappers for allocation, the new `xfree` function is the
equivalent for deallocation and provides a way to fully replace the malloc
implementation used by Neovim.
This commit is contained in:
Thiago de Arruda
2015-04-12 11:37:22 -03:00
parent ba10e311bd
commit 34c48aaf12
70 changed files with 1361 additions and 1353 deletions

View File

@@ -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;