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

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