diff options
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/env.c | 22 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 4 | ||||
-rw-r--r-- | src/nvim/os/job_private.h | 9 | ||||
-rw-r--r-- | src/nvim/os/pipe_process.c | 4 | ||||
-rw-r--r-- | src/nvim/os/pty_process.c | 4 | ||||
-rw-r--r-- | src/nvim/os/rstream.c | 10 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 10 | ||||
-rw-r--r-- | src/nvim/os/wstream.c | 16 |
8 files changed, 40 insertions, 39 deletions
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); } |