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

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