From df912e3540968a2a0b266e523ecc08bb2dc0ca20 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 10 Jul 2012 11:53:01 +0000 Subject: [PATCH] xfree is not particularly helpful, remove it. From Thomas Adam. --- arguments.c | 20 ++++++++----------- array.h | 5 ++--- cfg.c | 11 ++++++----- client.c | 2 +- cmd-attach-session.c | 4 +++- cmd-bind-key.c | 3 ++- cmd-break-pane.c | 4 ++-- cmd-capture-pane.c | 12 ++++++------ cmd-choose-buffer.c | 11 ++++++----- cmd-choose-client.c | 9 +++++---- cmd-choose-tree.c | 12 ++++++------ cmd-command-prompt.c | 20 +++++++++---------- cmd-confirm-before.c | 12 ++++++------ cmd-delete-buffer.c | 2 +- cmd-display-message.c | 3 ++- cmd-find-window.c | 9 +++++---- cmd-if-shell.c | 10 +++++----- cmd-join-pane.c | 4 ++-- cmd-link-window.c | 2 +- cmd-list-buffers.c | 3 ++- cmd-list-clients.c | 3 ++- cmd-list-panes.c | 3 ++- cmd-list-sessions.c | 3 ++- cmd-list-windows.c | 3 ++- cmd-list.c | 3 ++- cmd-load-buffer.c | 13 ++++++------- cmd-move-window.c | 2 +- cmd-new-session.c | 6 +++--- cmd-new-window.c | 4 ++-- cmd-paste-buffer.c | 2 +- cmd-rename-session.c | 2 +- cmd-respawn-pane.c | 3 ++- cmd-respawn-window.c | 3 ++- cmd-run-shell.c | 9 +++++---- cmd-save-buffer.c | 3 ++- cmd-set-buffer.c | 7 ++++--- cmd-set-option.c | 2 +- cmd-show-buffer.c | 7 ++++--- cmd-source-file.c | 6 ++++-- cmd-split-window.c | 8 ++++---- cmd-string.c | 27 ++++++++++++-------------- cmd-unbind-key.c | 6 ++++-- cmd.c | 45 +++++++++++++++++-------------------------- control.c | 5 +++-- environ.c | 21 +++++++++----------- format.c | 19 +++++++++--------- grid.c | 17 +++++++--------- input-keys.c | 2 +- input.c | 2 +- job.c | 5 +++-- key-bindings.c | 6 +++--- layout.c | 6 +++--- names.c | 9 +++++---- options.c | 17 ++++++++-------- paste.c | 15 ++++++++------- screen-write.c | 11 ++++++----- screen.c | 14 ++++++-------- server-client.c | 24 +++++++++-------------- server-fn.c | 3 ++- server-window.c | 3 ++- server.c | 10 +++++----- session.c | 10 ++++------ status.c | 45 +++++++++++++++++++------------------------ tmux.c | 21 ++++++++------------ tmux.h | 1 - tty-keys.c | 2 +- tty-term.c | 15 +++++++-------- tty.c | 10 +++++----- window-choose.c | 9 +++++---- window-clock.c | 3 ++- window-copy.c | 11 +++++------ window.c | 37 ++++++++++++++--------------------- xmalloc.c | 8 -------- 73 files changed, 329 insertions(+), 360 deletions(-) diff --git a/arguments.c b/arguments.c index 72a8577f..c15832a4 100644 --- a/arguments.c +++ b/arguments.c @@ -69,15 +69,14 @@ args_parse(const char *template, int argc, char **argv) if (opt < 0 || opt >= SCHAR_MAX) continue; if (opt == '?' || (ptr = strchr(template, opt)) == NULL) { - xfree(args->flags); - xfree(args); + free(args->flags); + free(args); return (NULL); } bit_set(args->flags, opt); if (ptr[1] == ':') { - if (args->values[opt] != NULL) - xfree(args->values[opt]); + free(args->values[opt]); args->values[opt] = xstrdup(optarg); } } @@ -98,13 +97,11 @@ args_free(struct args *args) cmd_free_argv(args->argc, args->argv); - for (i = 0; i < SCHAR_MAX; i++) { - if (args->values[i] != NULL) - xfree(args->values[i]); - } + for (i = 0; i < SCHAR_MAX; i++) + free(args->values[i]); - xfree(args->flags); - xfree(args); + free(args->flags); + free(args); } /* Print a set of arguments. */ @@ -183,8 +180,7 @@ args_has(struct args *args, u_char ch) void args_set(struct args *args, u_char ch, const char *value) { - if (args->values[ch] != NULL) - xfree(args->values[ch]); + free(args->values[ch]); if (value != NULL) args->values[ch] = xstrdup(value); else diff --git a/array.h b/array.h index 59ac356f..c811bf6d 100644 --- a/array.h +++ b/array.h @@ -109,13 +109,12 @@ } while (0) #define ARRAY_FREE(a) do { \ - if ((a)->list != NULL) \ - xfree((a)->list); \ + free((a)->list); \ ARRAY_INIT(a); \ } while (0) #define ARRAY_FREEALL(a) do { \ ARRAY_FREE(a); \ - xfree(a); \ + free(a); \ } while (0) #endif diff --git a/cfg.c b/cfg.c index 22a50d22..733238f3 100644 --- a/cfg.c +++ b/cfg.c @@ -21,6 +21,7 @@ #include #include +#include #include #include "tmux.h" @@ -117,14 +118,14 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) line = NULL; if (cmd_string_parse(buf, &cmdlist, &cause) != 0) { - xfree(buf); + free(buf); if (cause == NULL) continue; cfg_add_cause(causes, "%s: %u: %s", path, n, cause); - xfree(cause); + free(cause); continue; } else - xfree(buf); + free(buf); if (cmdlist == NULL) continue; cfg_cause = NULL; @@ -150,13 +151,13 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) if (cfg_cause != NULL) { cfg_add_cause( causes, "%s: %d: %s", path, n, cfg_cause); - xfree(cfg_cause); + free(cfg_cause); } } if (line != NULL) { cfg_add_cause(causes, "%s: %d: line continuation at end of file", path, n); - xfree(line); + free(line); } fclose(f); diff --git a/client.c b/client.c index 16498577..1326a97d 100644 --- a/client.c +++ b/client.c @@ -122,7 +122,7 @@ retry: if (unlink(path) != 0 && errno != ENOENT) return (-1); fd = server_start(lockfd, lockfile); - xfree(lockfile); + free(lockfile); close(lockfd); } diff --git a/cmd-attach-session.c b/cmd-attach-session.c index d07b727d..42ef89ce 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -18,6 +18,8 @@ #include +#include + #include "tmux.h" /* @@ -81,7 +83,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) } else { if (server_client_open(ctx->cmdclient, s, &cause) != 0) { ctx->error(ctx, "open terminal failed: %s", cause); - xfree(cause); + free(cause); return (-1); } diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 4f1b9f18..980e7ec9 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -74,7 +75,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx) cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause); if (cmdlist == NULL) { ctx->error(ctx, "%s", cause); - xfree(cause); + free(cause); return (-1); } diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 8e09774b..bcb6e6b9 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -81,7 +81,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = wp; name = default_window_name(w); window_set_name(w, name); - xfree(name); + free(name); layout_init(w); base_idx = options_get_number(&s->options, "base-index"); @@ -106,7 +106,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) cp = format_expand(ft, template); ctx->print(ctx, "%s", cp); - xfree(cp); + free(cp); format_free(ft); } diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 7c974f1f..236a51ca 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -62,7 +62,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); if (cause != NULL) { top = gd->hsize; - xfree(cause); + free(cause); } else if (n < 0 && (u_int) -n > gd->hsize) top = 0; else @@ -73,7 +73,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause); if (cause != NULL) { bottom = gd->hsize + gd->sy - 1; - xfree(cause); + free(cause); } else if (n < 0 && (u_int) -n > gd->hsize) bottom = 0; else @@ -96,7 +96,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) len += linelen; buf[len++] = '\n'; - xfree(line); + free(line); } limit = options_get_number(&global_options, "buffer-limit"); @@ -109,14 +109,14 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(buf); - xfree(cause); + free(buf); + free(cause); return (-1); } if (paste_replace(&global_buffers, buffer, buf, len) != 0) { ctx->error(ctx, "no buffer %d", buffer); - xfree(buf); + free(buf); return (-1); } diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index 0baa0a28..6c62cfa3 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -19,6 +19,7 @@ #include #include +#include #include "tmux.h" @@ -86,11 +87,11 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) xasprintf(&action_data, "%u", idx - 1); cdata->command = cmd_template_replace(action, action_data, 1); - xfree(action_data); + free(action_data); window_choose_add(wl->window->active, cdata); } - xfree(action); + free(action); window_choose_ready(wl->window->active, 0, cmd_choose_buffer_callback, cmd_choose_buffer_free); @@ -119,7 +120,7 @@ cmd_choose_buffer_free(struct window_choose_data *data) cdata->client->references--; - xfree(cdata->command); - xfree(cdata->ft_template); - xfree(cdata); + free(cdata->command); + free(cdata->ft_template); + free(cdata); } diff --git a/cmd-choose-client.c b/cmd-choose-client.c index fd6b2128..a20fec42 100644 --- a/cmd-choose-client.c +++ b/cmd-choose-client.c @@ -19,6 +19,7 @@ #include #include +#include #include "tmux.h" @@ -98,7 +99,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx) window_choose_add(wl->window->active, cdata); } - xfree(action); + free(action); window_choose_ready(wl->window->active, cur, cmd_choose_client_callback, cmd_choose_client_free); @@ -133,8 +134,8 @@ cmd_choose_client_free(struct window_choose_data *cdata) cdata->client->references--; - xfree(cdata->ft_template); - xfree(cdata->command); + free(cdata->ft_template); + free(cdata->command); format_free(cdata->ft); - xfree(cdata); + free(cdata); } diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index c29b2eab..0389bea3 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -19,6 +19,7 @@ #include #include +#include #include @@ -206,7 +207,7 @@ windows_only: ctx, s2, wm, final_win_template, final_win_action, idx_ses); - xfree(final_win_action); + free(final_win_action); } /* * If we're just drawing windows, don't consider moving on to @@ -215,8 +216,7 @@ windows_only: if (wflag && !sflag) break; } - if (final_win_template != NULL) - xfree(final_win_template); + free(final_win_template); window_choose_ready(wl->window->active, cur_win, cmd_choose_tree_callback, cmd_choose_tree_free); @@ -242,10 +242,10 @@ cmd_choose_tree_free(struct window_choose_data *cdata) cdata->session->references--; cdata->client->references--; - xfree(cdata->ft_template); - xfree(cdata->command); + free(cdata->ft_template); + free(cdata->command); format_free(cdata->ft); - xfree(cdata); + free(cdata); } diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index cd4d07ed..3105744f 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -138,7 +139,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) status_prompt_set(c, prompt, input, cmd_command_prompt_callback, cmd_command_prompt_free, cdata, 0); - xfree(prompt); + free(prompt); return (0); } @@ -157,7 +158,7 @@ cmd_command_prompt_callback(void *data, const char *s) return (0); new_template = cmd_template_replace(cdata->template, s, cdata->idx); - xfree(cdata->template); + free(cdata->template); cdata->template = new_template; /* @@ -169,7 +170,7 @@ cmd_command_prompt_callback(void *data, const char *s) input = strsep(&cdata->next_input, ","); status_prompt_update(c, prompt, input); - xfree(prompt); + free(prompt); cdata->idx++; return (1); } @@ -178,7 +179,7 @@ cmd_command_prompt_callback(void *data, const char *s) if (cause != NULL) { *cause = toupper((u_char) *cause); status_message_set(c, "%s", cause); - xfree(cause); + free(cause); } return (0); } @@ -205,11 +206,8 @@ cmd_command_prompt_free(void *data) { struct cmd_command_prompt_cdata *cdata = data; - if (cdata->inputs != NULL) - xfree(cdata->inputs); - if (cdata->prompts != NULL) - xfree(cdata->prompts); - if (cdata->template != NULL) - xfree(cdata->template); - xfree(cdata); + free(cdata->inputs); + free(cdata->prompts); + free(cdata->template); + free(cdata); } diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index 048465da..78c6bac4 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -17,6 +17,7 @@ */ #include +#include #include #include "tmux.h" @@ -87,7 +88,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx) ptr = copy = xstrdup(args->argv[0]); cmd = strsep(&ptr, " \t"); xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd); - xfree(copy); + free(copy); } cdata = xmalloc(sizeof *cdata); @@ -97,7 +98,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx) cmd_confirm_before_callback, cmd_confirm_before_free, cdata, PROMPT_SINGLE); - xfree(new_prompt); + free(new_prompt); return (1); } @@ -119,7 +120,7 @@ cmd_confirm_before_callback(void *data, const char *s) if (cause != NULL) { *cause = toupper((u_char) *cause); status_message_set(c, "%s", cause); - xfree(cause); + free(cause); } return (0); } @@ -144,7 +145,6 @@ cmd_confirm_before_free(void *data) { struct cmd_confirm_before_data *cdata = data; - if (cdata->cmd != NULL) - xfree(cdata->cmd); - xfree(cdata); + free(cdata->cmd); + free(cdata); } diff --git a/cmd-delete-buffer.c b/cmd-delete-buffer.c index 3f0578ed..f087b9a7 100644 --- a/cmd-delete-buffer.c +++ b/cmd-delete-buffer.c @@ -53,7 +53,7 @@ cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); + free(cause); return (-1); } diff --git a/cmd-display-message.c b/cmd-display-message.c index 058de1fa..3bc3a38c 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -93,7 +94,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx) else status_message_set(c, "%s", msg); - xfree(msg); + free(msg); format_free(ft); return (0); } diff --git a/cmd-find-window.c b/cmd-find-window.c index 9bd535f4..864f1821 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "tmux.h" @@ -134,7 +135,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) xasprintf(&sctx, "pane %u line %u: \"%s\"", i - 1, line + 1, sres); - xfree(sres); + free(sres); } } @@ -143,7 +144,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) break; } } - xfree(searchstr); + free(searchstr); if (ARRAY_LENGTH(&list_idx) == 0) { ctx->error(ctx, "no windows matching: %s", str); @@ -217,7 +218,7 @@ cmd_find_window_free(struct window_choose_data *cdata) cdata->session->references--; - xfree(cdata->ft_template); + free(cdata->ft_template); format_free(cdata->ft); - xfree(cdata); + free(cdata); } diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 6692a99c..bdd26e70 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "tmux.h" @@ -91,7 +92,7 @@ cmd_if_shell_callback(struct job *job) if (cmd_string_parse(cmd, &cmdlist, &cause) != 0) { if (cause != NULL) { ctx->error(ctx, "%s", cause); - xfree(cause); + free(cause); } return; } @@ -115,8 +116,7 @@ cmd_if_shell_free(void *data) if (ctx->curclient != NULL) ctx->curclient->references--; - if (cdata->cmd_else != NULL) - xfree(cdata->cmd_else); - xfree(cdata->cmd_if); - xfree(cdata); + free(cdata->cmd_else); + free(cdata->cmd_if); + free(cdata); } diff --git a/cmd-join-pane.c b/cmd-join-pane.c index 708430ca..602dcf66 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -116,14 +116,14 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window) size = args_strtonum(args, 'l', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "size %s", cause); - xfree(cause); + free(cause); return (-1); } } else if (args_has(args, 'p')) { percentage = args_strtonum(args, 'p', 0, 100, &cause); if (cause != NULL) { ctx->error(ctx, "percentage %s", cause); - xfree(cause); + free(cause); return (-1); } if (type == LAYOUT_TOPBOTTOM) diff --git a/cmd-link-window.c b/cmd-link-window.c index a278fe34..a9dcf621 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -56,7 +56,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) dflag = args_has(self->args, 'd'); if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { ctx->error(ctx, "can't link window: %s", cause); - xfree(cause); + free(cause); return (-1); } recalculate_sizes(); diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c index 777a6371..64fbd3f2 100644 --- a/cmd-list-buffers.c +++ b/cmd-list-buffers.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -60,7 +61,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx) line = format_expand(ft, template); ctx->print(ctx, "%s", line); - xfree(line); + free(line); format_free(ft); } diff --git a/cmd-list-clients.c b/cmd-list-clients.c index c818fd6d..2286ff98 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -18,6 +18,7 @@ #include +#include #include #include @@ -76,7 +77,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx) line = format_expand(ft, template); ctx->print(ctx, "%s", line); - xfree(line); + free(line); format_free(ft); } diff --git a/cmd-list-panes.c b/cmd-list-panes.c index 55559db7..3f9e672c 100644 --- a/cmd-list-panes.c +++ b/cmd-list-panes.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -135,7 +136,7 @@ cmd_list_panes_window(struct cmd *self, line = format_expand(ft, template); ctx->print(ctx, "%s", line); - xfree(line); + free(line); format_free(ft); n++; diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index 7dabfc08..1aa6dbaa 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -18,6 +18,7 @@ #include +#include #include #include @@ -60,7 +61,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx) line = format_expand(ft, template); ctx->print(ctx, "%s", line); - xfree(line); + free(line); format_free(ft); n++; diff --git a/cmd-list-windows.c b/cmd-list-windows.c index e0617335..241e64de 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -103,7 +104,7 @@ cmd_list_windows_session( line = format_expand(ft, template); ctx->print(ctx, "%s", line); - xfree(line); + free(line); format_free(ft); n++; diff --git a/cmd-list.c b/cmd-list.c index dc102dcc..08d5716f 100644 --- a/cmd-list.c +++ b/cmd-list.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -139,7 +140,7 @@ cmd_list_free(struct cmd_list *cmdlist) TAILQ_REMOVE(&cmdlist->list, cmd, qentry); cmd_free(cmd); } - xfree(cmdlist); + free(cmdlist); } size_t diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index 1e6b6024..83ab6078 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -62,7 +62,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); + free(cause); return (-1); } } @@ -76,7 +76,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer_ptr, &cause); if (error != 0) { ctx->error(ctx, "%s: %s", path, cause); - xfree(cause); + free(cause); return (-1); } return (1); @@ -127,15 +127,14 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) } if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { ctx->error(ctx, "no buffer %d", buffer); - xfree(pdata); + free(pdata); return (-1); } return (0); error: - if (pdata != NULL) - xfree(pdata); + free(pdata); if (f != NULL) fclose(f); return (-1); @@ -158,7 +157,7 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data) psize = EVBUFFER_LENGTH(c->stdin_data); if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) { - xfree(data); + free(data); return; } memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize); @@ -174,5 +173,5 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data) server_push_stderr(c); } - xfree(data); + free(data); } diff --git a/cmd-move-window.c b/cmd-move-window.c index 6268226e..4adad410 100644 --- a/cmd-move-window.c +++ b/cmd-move-window.c @@ -66,7 +66,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) dflag = args_has(self->args, 'd'); if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { ctx->error(ctx, "can't move window: %s", cause); - xfree(cause); + free(cause); return (-1); } server_unlink_window(src, wl); diff --git a/cmd-new-session.c b/cmd-new-session.c index 09413796..22ec16fb 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -130,7 +130,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (!detached && ctx->cmdclient != NULL) { if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) { ctx->error(ctx, "open terminal failed: %s", cause); - xfree(cause); + free(cause); return (-1); } } @@ -201,7 +201,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); if (s == NULL) { ctx->error(ctx, "create session failed: %s", cause); - xfree(cause); + free(cause); return (-1); } environ_free(&env); @@ -264,7 +264,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { cause = ARRAY_ITEM(&cfg_causes, i); window_copy_add(wp, "%s", cause); - xfree(cause); + free(cause); } ARRAY_FREE(&cfg_causes); } diff --git a/cmd-new-window.c b/cmd-new-window.c index 46bda8fc..3d9e9320 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -112,7 +112,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); if (wl == NULL) { ctx->error(ctx, "create window failed: %s", cause); - xfree(cause); + free(cause); return (-1); } if (!detached) { @@ -134,7 +134,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) cp = format_expand(ft, template); ctx->print(ctx, "%s", cp); - xfree(cp); + free(cp); format_free(ft); } diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index db20643c..2c367259 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -64,7 +64,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); + free(cause); return (-1); } } diff --git a/cmd-rename-session.c b/cmd-rename-session.c index 9f741d8d..bbae1872 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -59,7 +59,7 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); RB_REMOVE(sessions, &sessions, s); - xfree(s->name); + free(s->name); s->name = xstrdup(newname); RB_INSERT(sessions, &sessions, s); diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c index d1e52669..71e07831 100644 --- a/cmd-respawn-pane.c +++ b/cmd-respawn-pane.c @@ -19,6 +19,7 @@ #include +#include #include #include "tmux.h" @@ -79,7 +80,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx) cmd = NULL; if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { ctx->error(ctx, "respawn pane failed: %s", cause); - xfree(cause); + free(cause); environ_free(&env); return (-1); } diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c index 319262e5..c15ca376 100644 --- a/cmd-respawn-window.c +++ b/cmd-respawn-window.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -81,7 +82,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) cmd = NULL; if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { ctx->error(ctx, "respawn window failed: %s", cause); - xfree(cause); + free(cause); environ_free(&env); server_destroy_pane(wp); return (-1); diff --git a/cmd-run-shell.c b/cmd-run-shell.c index 85cd1e29..6a80d4ef 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "tmux.h" @@ -101,7 +102,7 @@ cmd_run_shell_callback(struct job *job) ctx->print(ctx, "%s", line); lines++; - xfree(line); + free(line); } cmd = cdata->cmd; @@ -119,7 +120,7 @@ cmd_run_shell_callback(struct job *job) ctx->print(ctx, "%s", msg); else ctx->info(ctx, "%s", msg); - xfree(msg); + free(msg); } } @@ -136,6 +137,6 @@ cmd_run_shell_free(void *data) if (ctx->curclient != NULL) ctx->curclient->references--; - xfree(cdata->cmd); - xfree(cdata); + free(cdata->cmd); + free(cdata); } diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index 80f9d572..875cbbbb 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "tmux.h" @@ -62,7 +63,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); + free(cause); return (-1); } diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index 4f3d87a7..73e8b316 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -60,14 +61,14 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); - xfree(pdata); + free(cause); + free(pdata); return (-1); } if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { ctx->error(ctx, "no buffer %d", buffer); - xfree(pdata); + free(pdata); return (-1); } diff --git a/cmd-set-option.c b/cmd-set-option.c index ff138873..8e55a4fc 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -257,7 +257,7 @@ cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx, o = options_set_string(oo, oe->name, "%s", newval); - xfree(newval); + free(newval); return (o); } diff --git a/cmd-show-buffer.c b/cmd-show-buffer.c index 17d4509d..6dbc0c37 100644 --- a/cmd-show-buffer.c +++ b/cmd-show-buffer.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -61,7 +62,7 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); if (cause != NULL) { ctx->error(ctx, "buffer %s", cause); - xfree(cause); + free(cause); return (-1); } @@ -103,9 +104,9 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) buf[len] = '\0'; ctx->print(ctx, "%s", buf); } - xfree(buf); + free(buf); - xfree(in); + free(in); return (0); } diff --git a/cmd-source-file.c b/cmd-source-file.c index aa05d362..3804f0ec 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -18,6 +18,8 @@ #include +#include + #include "tmux.h" /* @@ -59,13 +61,13 @@ cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx) for (i = 0; i < ARRAY_LENGTH(&causes); i++) { cause = ARRAY_ITEM(&causes, i); window_copy_add(wp, "%s", cause); - xfree(cause); + free(cause); } } else { for (i = 0; i < ARRAY_LENGTH(&causes); i++) { cause = ARRAY_ITEM(&causes, i); ctx->print(ctx, "%s", cause); - xfree(cause); + free(cause); } } ARRAY_FREE(&causes); diff --git a/cmd-split-window.c b/cmd-split-window.c index db00a67b..c8afdaba 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -94,7 +94,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) size = args_strtonum(args, 'l', 0, INT_MAX, &cause); if (cause != NULL) { xasprintf(&new_cause, "size %s", cause); - xfree(cause); + free(cause); cause = new_cause; goto error; } @@ -102,7 +102,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause); if (cause != NULL) { xasprintf(&new_cause, "percentage %s", cause); - xfree(cause); + free(cause); cause = new_cause; goto error; } @@ -151,7 +151,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) cp = format_expand(ft, template); ctx->print(ctx, "%s", cp); - xfree(cp); + free(cp); format_free(ft); } @@ -163,6 +163,6 @@ error: if (new_wp != NULL) window_remove_pane(w, new_wp); ctx->error(ctx, "create pane failed: %s", cause); - xfree(cause); + free(cause); return (-1); } diff --git a/cmd-string.c b/cmd-string.c index 9384f9e2..93beb3ca 100644 --- a/cmd-string.c +++ b/cmd-string.c @@ -87,7 +87,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) buf = xrealloc(buf, 1, len + strlen(t) + 1); strlcpy(buf + len, t, strlen(t) + 1); len += strlen(t); - xfree(t); + free(t); break; case '"': if ((t = cmd_string_string(s, &p, '"', 1)) == NULL) @@ -95,7 +95,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) buf = xrealloc(buf, 1, len + strlen(t) + 1); strlcpy(buf + len, t, strlen(t) + 1); len += strlen(t); - xfree(t); + free(t); break; case '$': if ((t = cmd_string_variable(s, &p)) == NULL) @@ -103,7 +103,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) buf = xrealloc(buf, 1, len + strlen(t) + 1); strlcpy(buf + len, t, strlen(t) + 1); len += strlen(t); - xfree(t); + free(t); break; case '#': /* Comment: discard rest of line. */ @@ -152,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) buf = xrealloc(buf, 1, len + strlen(t) + 1); strlcpy(buf + len, t, strlen(t) + 1); len += strlen(t); - xfree(t); + free(t); break; } /* FALLTHROUGH */ @@ -170,13 +170,12 @@ error: xasprintf(cause, "invalid or unknown command: %s", s); out: - if (buf != NULL) - xfree(buf); + free(buf); if (argv != NULL) { for (i = 0; i < argc; i++) - xfree(argv[i]); - xfree(argv); + free(argv[i]); + free(argv); } return (rval); @@ -224,7 +223,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc) buf = xrealloc(buf, 1, len + strlen(t) + 1); strlcpy(buf + len, t, strlen(t) + 1); len += strlen(t); - xfree(t); + free(t); continue; } @@ -239,8 +238,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc) return (buf); error: - if (buf != NULL) - xfree(buf); + free(buf); return (NULL); } @@ -303,14 +301,13 @@ cmd_string_variable(const char *s, size_t *p) buf[len] = '\0'; envent = environ_find(&global_environ, buf); - xfree(buf); + free(buf); if (envent == NULL) return (xstrdup("")); return (xstrdup(envent->value)); error: - if (buf != NULL) - xfree(buf); + free(buf); return (NULL); } @@ -334,7 +331,7 @@ cmd_string_expand_tilde(const char *s, size_t *p) return (NULL); if ((pw = getpwnam(username)) != NULL) home = pw->pw_dir; - xfree(username); + free(username); } if (home == NULL) return (NULL); diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 4a061061..ac6c0c0f 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -18,6 +18,8 @@ #include +#include + #include "tmux.h" /* @@ -100,7 +102,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) while (!RB_EMPTY(mtab->tree)) { mbind = RB_ROOT(mtab->tree); RB_REMOVE(mode_key_tree, mtab->tree, mbind); - xfree(mbind); + free(mbind); } return (0); } @@ -109,7 +111,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) mtmp.mode = !!args_has(args, 'c'); if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { RB_REMOVE(mode_key_tree, mtab->tree, mbind); - xfree(mbind); + free(mbind); } return (0); } diff --git a/cmd.c b/cmd.c index 5f97a854..eb2fd75c 100644 --- a/cmd.c +++ b/cmd.c @@ -198,11 +198,9 @@ cmd_free_argv(int argc, char **argv) if (argc == 0) return; - for (i = 0; i < argc; i++) { - if (argv[i] != NULL) - xfree(argv[i]); - } - xfree(argv); + for (i = 0; i < argc; i++) + free(argv[i]); + free(argv); } struct cmd * @@ -291,9 +289,8 @@ cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx) void cmd_free(struct cmd *cmd) { - if (cmd->args != NULL) - args_free(cmd->args); - xfree(cmd); + args_free(cmd->args); + free(cmd); } size_t @@ -507,7 +504,7 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg) if (c == NULL) ctx->error(ctx, "client not found: %s", tmparg); - xfree(tmparg); + free(tmparg); return (c); } @@ -767,7 +764,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached) /* An empty session name is the current session. */ if (*tmparg == '\0') { - xfree(tmparg); + free(tmparg); return (cmd_current_session(ctx, prefer_unattached)); } @@ -786,7 +783,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached) ctx->error(ctx, "session not found: %s", tmparg); } - xfree(tmparg); + free(tmparg); return (s); } @@ -861,7 +858,7 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp) goto not_found; if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (wl); no_colon: @@ -899,8 +896,7 @@ no_session: ctx->error(ctx, "multiple sessions: %s", arg); else ctx->error(ctx, "session not found: %s", arg); - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (NULL); not_found: @@ -908,8 +904,7 @@ not_found: ctx->error(ctx, "multiple windows: %s", arg); else ctx->error(ctx, "window not found: %s", arg); - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (NULL); } @@ -1000,8 +995,7 @@ cmd_find_index(struct cmd_ctx *ctx, const char *arg, struct session **sp) } else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1) goto invalid_index; - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (idx); no_colon: @@ -1040,8 +1034,7 @@ no_session: ctx->error(ctx, "multiple sessions: %s", arg); else ctx->error(ctx, "session not found: %s", arg); - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (-2); invalid_index: @@ -1049,8 +1042,7 @@ invalid_index: goto not_found; ctx->error(ctx, "invalid index: %s", arg); - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (-2); not_found: @@ -1058,8 +1050,7 @@ not_found: ctx->error(ctx, "multiple windows: %s", arg); else ctx->error(ctx, "window not found: %s", arg); - if (sessptr != NULL) - xfree(sessptr); + free(sessptr); return (-2); } @@ -1153,7 +1144,7 @@ cmd_find_pane(struct cmd_ctx *ctx, goto lookup_string; } - xfree(winptr); + free(winptr); return (wl); lookup_string: @@ -1163,7 +1154,7 @@ lookup_string: goto error; } - xfree(winptr); + free(winptr); return (wl); no_period: @@ -1189,7 +1180,7 @@ lookup_window: return (wl); error: - xfree(winptr); + free(winptr); return (NULL); } diff --git a/control.c b/control.c index 52ccb202..3dc7bc2a 100644 --- a/control.c +++ b/control.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "tmux.h" @@ -110,12 +111,12 @@ control_callback(struct client *c, int closed, unused void *data) if (cmd_string_parse(line, &cmdlist, &cause) != 0) { control_write(c, "%%error in line \"%s\": %s", line, cause); - xfree(cause); + free(cause); } else { cmd_list_exec(cmdlist, &ctx); cmd_list_free(cmdlist); } - xfree(line); + free(line); } } diff --git a/environ.c b/environ.c index 4c4af98f..2374d764 100644 --- a/environ.c +++ b/environ.c @@ -51,10 +51,9 @@ environ_free(struct environ *env) while (!RB_EMPTY(env)) { envent = RB_ROOT(env); RB_REMOVE(environ, env, envent); - xfree(envent->name); - if (envent->value != NULL) - xfree(envent->value); - xfree(envent); + free(envent->name); + free(envent->value); + free(envent); } } @@ -85,8 +84,7 @@ environ_set(struct environ *env, const char *name, const char *value) struct environ_entry *envent; if ((envent = environ_find(env, name)) != NULL) { - if (envent->value != NULL) - xfree(envent->value); + free(envent->value); if (value != NULL) envent->value = xstrdup(value); else @@ -117,7 +115,7 @@ environ_put(struct environ *env, const char *var) name[strcspn(name, "=")] = '\0'; environ_set(env, name, value); - xfree(name); + free(name); } /* Unset an environment variable. */ @@ -129,10 +127,9 @@ environ_unset(struct environ *env, const char *name) if ((envent = environ_find(env, name)) == NULL) return; RB_REMOVE(environ, env, envent); - xfree(envent->name); - if (envent->value != NULL) - xfree(envent->value); - xfree(envent); + free(envent->name); + free(envent->value); + free(envent); } /* @@ -152,7 +149,7 @@ environ_update(const char *vars, struct environ *srcenv, struct environ *dstenv) else environ_set(dstenv, envent->name, envent->value); } - xfree(copyvars); + free(copyvars); } /* Push environment into the real environment - use after fork(). */ diff --git a/format.c b/format.c index 8fe4acf4..bc638448 100644 --- a/format.c +++ b/format.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -102,12 +103,12 @@ format_free(struct format_tree *ft) fe_next = RB_NEXT(format_tree, ft, fe); RB_REMOVE(format_tree, ft, fe); - xfree(fe->value); - xfree(fe->key); - xfree(fe); + free(fe->value); + free(fe->key); + free(fe); } - xfree (ft); + free (ft); } /* Add a key-value pair. */ @@ -195,11 +196,11 @@ format_replace(struct format_tree *ft, memcpy(*buf + *off, value, valuelen); *off += valuelen; - xfree(copy); + free(copy); return (0); fail: - xfree(copy); + free(copy); return (-1); } @@ -351,8 +352,8 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) format_add(ft, "window_active", "%d", wl == s->curw); format_add(ft, "window_panes", "%u", window_count_panes(w)); - xfree(flags); - xfree(layout); + free(flags); + free(layout); } /* Set default format keys for a window pane. */ @@ -403,5 +404,5 @@ format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb) format_add(ft, "buffer_size", "%zu", pb->size); format_add(ft, "buffer_sample", "%s", pb_print); - xfree(pb_print); + free(pb_print); } diff --git a/grid.c b/grid.c index a92f43f4..91ec7856 100644 --- a/grid.c +++ b/grid.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -98,15 +99,13 @@ grid_destroy(struct grid *gd) for (yy = 0; yy < gd->hsize + gd->sy; yy++) { gl = &gd->linedata[yy]; - if (gl->celldata != NULL) - xfree(gl->celldata); - if (gl->utf8data != NULL) - xfree(gl->utf8data); + free(gl->celldata); + free(gl->utf8data); } - xfree(gd->linedata); + free(gd->linedata); - xfree(gd); + free(gd); } /* Compare grids. */ @@ -373,10 +372,8 @@ grid_clear_lines(struct grid *gd, u_int py, u_int ny) for (yy = py; yy < py + ny; yy++) { gl = &gd->linedata[yy]; - if (gl->celldata != NULL) - xfree(gl->celldata); - if (gl->utf8data != NULL) - xfree(gl->utf8data); + free(gl->celldata); + free(gl->utf8data); memset(gl, 0, sizeof *gl); } } diff --git a/input-keys.c b/input-keys.c index 11743b75..bd1c6157 100644 --- a/input-keys.c +++ b/input-keys.c @@ -164,7 +164,7 @@ input_key(struct window_pane *wp, int key) if (options_get_number(&wp->window->options, "xterm-keys")) { if ((out = xterm_keys_lookup(key)) != NULL) { bufferevent_write(wp->event, out, strlen(out)); - xfree(out); + free(out); return; } } diff --git a/input.c b/input.c index eee0f78d..7a9f0e48 100644 --- a/input.c +++ b/input.c @@ -853,7 +853,7 @@ input_reply(struct input_ctx *ictx, const char *fmt, ...) va_end(ap); bufferevent_write(ictx->wp->event, reply, strlen(reply)); - xfree(reply); + free(reply); } /* Clear saved state. */ diff --git a/job.c b/job.c index e2e8ab48..bc630128 100644 --- a/job.c +++ b/job.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -117,7 +118,7 @@ job_free(struct job *job) log_debug("free job %p: %s", job, job->cmd); LIST_REMOVE(job, lentry); - xfree(job->cmd); + free(job->cmd); if (job->freefn != NULL && job->data != NULL) job->freefn(job->data); @@ -129,7 +130,7 @@ job_free(struct job *job) if (job->fd != -1) close(job->fd); - xfree(job); + free(job); } /* Job buffer error callback. */ diff --git a/key-bindings.c b/key-bindings.c index 8511ea7c..8434cc03 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -90,7 +90,7 @@ key_bindings_clean(void) bd = RB_ROOT(&dead_key_bindings); RB_REMOVE(key_bindings, &dead_key_bindings, bd); cmd_list_free(bd->cmdlist); - xfree(bd); + free(bd); } } @@ -216,7 +216,7 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...) *msg = toupper((u_char) *msg); status_message_set(ctx->curclient, "%s", msg); - xfree(msg); + free(msg); } void printflike2 @@ -258,7 +258,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...) *msg = toupper((u_char) *msg); status_message_set(ctx->curclient, "%s", msg); - xfree(msg); + free(msg); } void diff --git a/layout.c b/layout.c index c803aef6..a0e624fb 100644 --- a/layout.c +++ b/layout.c @@ -78,7 +78,7 @@ layout_free_cell(struct layout_cell *lc) break; } - xfree(lc); + free(lc); } void @@ -781,8 +781,8 @@ layout_list_add(struct window *w) TAILQ_REMOVE(&w->layout_list, ll, entry); w->layout_list_size--; - xfree(ll->layout); - xfree(ll); + free(ll->layout); + free(ll); } } diff --git a/names.c b/names.c index a20d8cfc..de4b30cc 100644 --- a/names.c +++ b/names.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -73,12 +74,12 @@ window_name_callback(unused int fd, unused short events, void *data) wname = parse_window_name(name + 1); else wname = parse_window_name(name); - xfree(name); + free(name); } if (w->active->fd == -1) { xasprintf(&name, "%s[dead]", wname); - xfree(wname); + free(wname); wname = name; } @@ -86,7 +87,7 @@ window_name_callback(unused int fd, unused short events, void *data) window_set_name(w, wname); server_status_window(w); } - xfree(wname); + free(wname); } char * @@ -122,6 +123,6 @@ parse_window_name(const char *in) if (*name == '/') name = basename(name); name = xstrdup(name); - xfree(copy); + free(copy); return (name); } diff --git a/options.c b/options.c index 9298ab11..ec036741 100644 --- a/options.c +++ b/options.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "tmux.h" @@ -51,10 +52,10 @@ options_free(struct options *oo) while (!RB_EMPTY(&oo->tree)) { o = RB_ROOT(&oo->tree); RB_REMOVE(options_tree, &oo->tree, o); - xfree(o->name); + free(o->name); if (o->type == OPTIONS_STRING) - xfree(o->str); - xfree(o); + free(o->str); + free(o); } } @@ -92,10 +93,10 @@ options_remove(struct options *oo, const char *name) return; RB_REMOVE(options_tree, &oo->tree, o); - xfree(o->name); + free(o->name); if (o->type == OPTIONS_STRING) - xfree(o->str); - xfree(o); + free(o->str); + free(o); } struct options_entry *printflike3 @@ -109,7 +110,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...) o->name = xstrdup(name); RB_INSERT(options_tree, &oo->tree, o); } else if (o->type == OPTIONS_STRING) - xfree(o->str); + free(o->str); va_start(ap, fmt); o->type = OPTIONS_STRING; @@ -140,7 +141,7 @@ options_set_number(struct options *oo, const char *name, long long value) o->name = xstrdup(name); RB_INSERT(options_tree, &oo->tree, o); } else if (o->type == OPTIONS_STRING) - xfree(o->str); + free(o->str); o->type = OPTIONS_NUMBER; o->num = value; diff --git a/paste.c b/paste.c index cc43d6e9..3dcd6008 100644 --- a/paste.c +++ b/paste.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -70,8 +71,8 @@ paste_free_top(struct paste_stack *ps) pb = ARRAY_FIRST(ps); ARRAY_REMOVE(ps, 0); - xfree(pb->data); - xfree(pb); + free(pb->data); + free(pb); return (0); } @@ -88,8 +89,8 @@ paste_free_index(struct paste_stack *ps, u_int idx) pb = ARRAY_ITEM(ps, idx); ARRAY_REMOVE(ps, idx); - xfree(pb->data); - xfree(pb); + free(pb->data); + free(pb); return (0); } @@ -108,8 +109,8 @@ paste_add(struct paste_stack *ps, char *data, size_t size, u_int limit) while (ARRAY_LENGTH(ps) >= limit) { pb = ARRAY_LAST(ps); - xfree(pb->data); - xfree(pb); + free(pb->data); + free(pb); ARRAY_TRUNC(ps, 1); } @@ -137,7 +138,7 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size) return (-1); pb = ARRAY_ITEM(ps, idx); - xfree(pb->data); + free(pb->data); pb->data = data; pb->size = size; diff --git a/screen-write.c b/screen-write.c index 90511e30..ee038e7d 100644 --- a/screen-write.c +++ b/screen-write.c @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -102,8 +103,8 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...) size = screen_write_strlen(utf8flag, "%s", msg2); - xfree(msg); - xfree(msg2); + free(msg); + free(msg2); return (size); } @@ -141,7 +142,7 @@ screen_write_strlen(int utf8flag, const char *fmt, ...) } } - xfree(msg); + free(msg); return (size); } @@ -215,7 +216,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen, } } - xfree(msg); + free(msg); } /* Write string, similar to nputs, but with embedded formatting (#[]). */ @@ -285,7 +286,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx, } } - xfree(msg); + free(msg); } /* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */ diff --git a/screen.c b/screen.c index ed5fcfce..7ffe2a24 100644 --- a/screen.c +++ b/screen.c @@ -70,10 +70,9 @@ screen_reinit(struct screen *s) void screen_free(struct screen *s) { - if (s->tabs != NULL) - xfree(s->tabs); - xfree(s->title); - xfree(s->ccolour); + free(s->tabs); + free(s->title); + free(s->ccolour); grid_destroy(s->grid); } @@ -83,8 +82,7 @@ screen_reset_tabs(struct screen *s) { u_int i; - if (s->tabs != NULL) - xfree(s->tabs); + free(s->tabs); if ((s->tabs = bit_alloc(screen_size_x(s))) == NULL) fatal("bit_alloc failed"); @@ -104,7 +102,7 @@ screen_set_cursor_style(struct screen *s, u_int style) void screen_set_cursor_colour(struct screen *s, const char *colour_string) { - xfree(s->ccolour); + free(s->ccolour); s->ccolour = xstrdup(colour_string); } @@ -116,7 +114,7 @@ screen_set_title(struct screen *s, const char *title) strlcpy(tmp, title, sizeof tmp); - xfree(s->title); + free(s->title); s->title = xstrdup(tmp); } diff --git a/server-client.c b/server-client.c index 0e095af0..20f539ae 100644 --- a/server-client.c +++ b/server-client.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "tmux.h" @@ -151,31 +152,25 @@ server_client_lost(struct client *c) status_free_jobs(&c->status_old); screen_free(&c->status); - if (c->title != NULL) - xfree(c->title); + free(c->title); evtimer_del(&c->repeat_timer); if (event_initialized(&c->identify_timer)) evtimer_del(&c->identify_timer); - if (c->message_string != NULL) - xfree(c->message_string); + free(c->message_string); if (event_initialized (&c->message_timer)) evtimer_del(&c->message_timer); for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { msg = &ARRAY_ITEM(&c->message_log, i); - xfree(msg->msg); + free(msg->msg); } ARRAY_FREE(&c->message_log); - if (c->prompt_string != NULL) - xfree(c->prompt_string); - if (c->prompt_buffer != NULL) - xfree(c->prompt_buffer); - - if (c->cwd != NULL) - xfree(c->cwd); + free(c->prompt_string); + free(c->prompt_buffer); + free(c->cwd); environ_free(&c->environ); @@ -662,12 +657,11 @@ server_client_set_title(struct client *c) title = status_replace(c, NULL, NULL, NULL, template, time(NULL), 1); if (c->title == NULL || strcmp(title, c->title) != 0) { - if (c->title != NULL) - xfree(c->title); + free(c->title); c->title = xstrdup(title); tty_set_title(&c->tty, c->title); } - xfree(title); + free(title); } /* Dispatch message from client. */ diff --git a/server-fn.c b/server-fn.c index 1c55e16b..bea64178 100644 --- a/server-fn.c +++ b/server-fn.c @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -393,7 +394,7 @@ server_destroy_session_group(struct session *s) TAILQ_FOREACH(s, &sg->sessions, gentry) server_destroy_session(s); TAILQ_REMOVE(&session_groups, sg, entry); - xfree(sg); + free(sg); } } diff --git a/server-window.c b/server-window.c index c852acf1..8f3e2b63 100644 --- a/server-window.c +++ b/server-window.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "tmux.h" @@ -211,7 +212,7 @@ server_window_check_content( return (0); if ((found = window_pane_search(wp, ptr, NULL)) == NULL) return (0); - xfree(found); + free(found); if (options_get_number(&s->options, "bell-on-alert")) ring_bell(s); diff --git a/server.c b/server.c index bc0e4ab9..740f71d9 100644 --- a/server.c +++ b/server.c @@ -162,7 +162,7 @@ server_start(int lockfd, char *lockfile) server_client_create(pair[1]); unlink(lockfile); - xfree(lockfile); + free(lockfile); close(lockfd); if (access(SYSTEM_CFG, R_OK) == 0) @@ -185,7 +185,7 @@ server_start(int lockfd, char *lockfile) for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { cause = ARRAY_ITEM(&cfg_causes, i); window_copy_add(wp, "%s", cause); - xfree(cause); + free(cause); } ARRAY_FREE(&cfg_causes); } @@ -275,8 +275,8 @@ server_clean_dead(void) next_s = RB_NEXT(sessions, &dead_sessions, s); if (s->references == 0) { RB_REMOVE(sessions, &dead_sessions, s); - xfree(s->name); - xfree(s); + free(s->name); + free(s); } s = next_s; } @@ -286,7 +286,7 @@ server_clean_dead(void) if (c == NULL || c->references != 0) continue; ARRAY_SET(&dead_clients, i, NULL); - xfree(c); + free(c); } } diff --git a/session.c b/session.c index 75ea8b0c..21929d8b 100644 --- a/session.c +++ b/session.c @@ -126,8 +126,7 @@ session_create(const char *name, const char *cmd, const char *cwd, s->name = NULL; do { s->idx = next_session++; - if (s->name != NULL) - xfree (s->name); + free (s->name); xasprintf(&s->name, "%u", s->idx); } while (RB_FIND(sessions, &sessions, s) != NULL); } @@ -157,8 +156,7 @@ session_destroy(struct session *s) RB_REMOVE(sessions, &sessions, s); notify_session_closed(s); - if (s->tio != NULL) - xfree(s->tio); + free(s->tio); session_group_remove(s); environ_free(&s->environ); @@ -172,7 +170,7 @@ session_destroy(struct session *s) winlink_remove(&s->windows, wl); } - xfree(s->cwd); + free(s->cwd); RB_INSERT(sessions, &dead_sessions, s); } @@ -495,7 +493,7 @@ session_group_remove(struct session *s) TAILQ_REMOVE(&sg->sessions, TAILQ_FIRST(&sg->sessions), gentry); if (TAILQ_EMPTY(&sg->sessions)) { TAILQ_REMOVE(&session_groups, sg, entry); - xfree(sg); + free(sg); } } diff --git a/status.c b/status.c index a1c23286..6cbdc6c4 100644 --- a/status.c +++ b/status.c @@ -222,8 +222,7 @@ status_redraw(struct client *c) /* Calculate the total size needed for the window list. */ wlstart = wloffset = wlwidth = 0; RB_FOREACH(wl, winlinks, &s->windows) { - if (wl->status_text != NULL) - xfree(wl->status_text); + free(wl->status_text); memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell); wl->status_text = status_print(c, wl, t, &wl->status_cell); wl->status_width = @@ -372,10 +371,8 @@ draw: screen_write_stop(&ctx); out: - if (left != NULL) - xfree(left); - if (right != NULL) - xfree(right); + free(left); + free(right); if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status); @@ -491,8 +488,7 @@ do_replace: } out: - if (freeptr != NULL) - xfree(freeptr); + free(freeptr); return; skip_to: @@ -572,7 +568,7 @@ status_find_job(struct client *c, char **iptr) cmd[len++] = **iptr; } if (**iptr == '\0') /* no terminating ) */ { - xfree(cmd); + free(cmd); return (NULL); } (*iptr)++; /* skip final ) */ @@ -582,7 +578,7 @@ status_find_job(struct client *c, char **iptr) so_find.cmd = cmd; so = RB_FIND(status_out_tree, &c->status_new, &so_find); if (so != NULL && so->out != NULL) { - xfree(cmd); + free(cmd); return (so->out); } @@ -600,7 +596,7 @@ status_find_job(struct client *c, char **iptr) /* Lookup in the old tree. */ so_find.cmd = cmd; so = RB_FIND(status_out_tree, &c->status_old, &so_find); - xfree(cmd); + free(cmd); if (so != NULL) return (so->out); return (NULL); @@ -618,10 +614,9 @@ status_free_jobs(struct status_out_tree *sotree) so_next = RB_NEXT(status_out_tree, sotree, so); RB_REMOVE(status_out_tree, sotree, so); - if (so->out != NULL) - xfree(so->out); - xfree(so->cmd); - xfree(so); + free(so->out); + free(so->cmd); + free(so); } } @@ -778,7 +773,7 @@ status_message_set(struct client *c, const char *fmt, ...) limit = ARRAY_LENGTH(&c->message_log) - limit; for (i = 0; i < limit; i++) { msg = &ARRAY_FIRST(&c->message_log); - xfree(msg->msg); + free(msg->msg); ARRAY_REMOVE(&c->message_log, 0); } } @@ -803,7 +798,7 @@ status_message_clear(struct client *c) if (c->message_string == NULL) return; - xfree(c->message_string); + free(c->message_string); c->message_string = NULL; c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); @@ -912,10 +907,10 @@ status_prompt_clear(struct client *c) if (c->prompt_freefn != NULL && c->prompt_data != NULL) c->prompt_freefn(c->prompt_data); - xfree(c->prompt_string); + free(c->prompt_string); c->prompt_string = NULL; - xfree(c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = NULL; c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); @@ -928,11 +923,11 @@ status_prompt_clear(struct client *c) void status_prompt_update(struct client *c, const char *msg, const char *input) { - xfree(c->prompt_string); + free(c->prompt_string); c->prompt_string = status_replace(c, NULL, NULL, NULL, msg, time(NULL), 0); - xfree(c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input, time(NULL), 0); c->prompt_index = strlen(c->prompt_buffer); @@ -1109,7 +1104,7 @@ status_prompt_key(struct client *c, int key) memcpy(first, s, strlen(s)); c->prompt_index = (first - c->prompt_buffer) + strlen(s); - xfree(s); + free(s); c->flags |= CLIENT_STATUS; break; @@ -1250,7 +1245,7 @@ status_prompt_key(struct client *c, int key) histstr = status_prompt_up_history(&c->prompt_hindex); if (histstr == NULL) break; - xfree(c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = xstrdup(histstr); c->prompt_index = strlen(c->prompt_buffer); c->flags |= CLIENT_STATUS; @@ -1259,7 +1254,7 @@ status_prompt_key(struct client *c, int key) histstr = status_prompt_down_history(&c->prompt_hindex); if (histstr == NULL) break; - xfree(c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = xstrdup(histstr); c->prompt_index = strlen(c->prompt_buffer); c->flags |= CLIENT_STATUS; @@ -1383,7 +1378,7 @@ status_prompt_add_history(const char *line) return; if (size == PROMPT_HISTORY) { - xfree(ARRAY_FIRST(&status_prompt_history)); + free(ARRAY_FIRST(&status_prompt_history)); ARRAY_REMOVE(&status_prompt_history, 0); } diff --git a/tmux.c b/tmux.c index 9a305c02..e01017c9 100644 --- a/tmux.c +++ b/tmux.c @@ -73,7 +73,7 @@ logfile(const char *name) if (debug_level > 0) { xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); log_open(debug_level, path); - xfree(path); + free(path); } } @@ -252,8 +252,7 @@ main(int argc, char **argv) flags &= ~IDENTIFY_256COLOURS; break; case 'c': - if (shell_cmd != NULL) - xfree(shell_cmd); + free(shell_cmd); shell_cmd = xstrdup(optarg); break; case 'C': @@ -263,24 +262,21 @@ main(int argc, char **argv) flags |= IDENTIFY_CONTROL; break; case 'f': - if (cfg_file != NULL) - xfree(cfg_file); + free(cfg_file); cfg_file = xstrdup(optarg); break; case 'l': login_shell = 1; break; case 'L': - if (label != NULL) - xfree(label); + free(label); label = xstrdup(optarg); break; case 'q': quiet = 1; break; case 'S': - if (path != NULL) - xfree(path); + free(path); path = xstrdup(optarg); break; case 'u': @@ -360,7 +356,7 @@ main(int argc, char **argv) } xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG); if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { - xfree(cfg_file); + free(cfg_file); cfg_file = NULL; } } @@ -387,11 +383,10 @@ main(int argc, char **argv) } } } - if (label != NULL) - xfree(label); + free(label); if (realpath(path, socket_path) == NULL) strlcpy(socket_path, path, sizeof socket_path); - xfree(path); + free(path); /* Set process title. */ setproctitle("%s (%s)", __progname, socket_path); diff --git a/tmux.h b/tmux.h index 02237f8a..2538a97f 100644 --- a/tmux.h +++ b/tmux.h @@ -2224,7 +2224,6 @@ char *xstrdup(const char *); void *xcalloc(size_t, size_t); void *xmalloc(size_t); void *xrealloc(void *, size_t, size_t); -void xfree(void *); int printflike2 xasprintf(char **, const char *, ...); int xvasprintf(char **, const char *, va_list); int printflike3 xsnprintf(char *, size_t, const char *, ...); diff --git a/tty-keys.c b/tty-keys.c index 9390981e..c90eb71e 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -384,7 +384,7 @@ tty_keys_free1(struct tty_key *tk) tty_keys_free1(tk->left); if (tk->right != NULL) tty_keys_free1(tk->right); - xfree(tk); + free(tk); } /* Lookup a key in the tree. */ diff --git a/tty-term.c b/tty-term.c index d79cbf2f..f088d251 100644 --- a/tty-term.c +++ b/tty-term.c @@ -252,7 +252,7 @@ tty_term_override(struct tty_term *term, const char *overrides) *ptr++ = '\0'; val = xstrdup(ptr); if (strunvis(val, ptr) == -1) { - xfree(val); + free(val); val = xstrdup(ptr); } } else if (entstr[strlen(entstr) - 1] == '@') { @@ -278,7 +278,7 @@ tty_term_override(struct tty_term *term, const char *overrides) break; case TTYCODE_STRING: if (code->type == TTYCODE_STRING) - xfree(code->value.string); + free(code->value.string); code->value.string = xstrdup(val); code->type = ent->type; break; @@ -296,12 +296,11 @@ tty_term_override(struct tty_term *term, const char *overrides) } } - if (val != NULL) - xfree(val); + free(val); } } - xfree(s); + free(s); } struct tty_term * @@ -463,10 +462,10 @@ tty_term_free(struct tty_term *term) for (i = 0; i < NTTYCODE; i++) { if (term->codes[i].type == TTYCODE_STRING) - xfree(term->codes[i].value.string); + free(term->codes[i].value.string); } - xfree(term->name); - xfree(term); + free(term->name); + free(term); } int diff --git a/tty.c b/tty.c index ca65bdb3..d40e95d7 100644 --- a/tty.c +++ b/tty.c @@ -345,11 +345,11 @@ tty_free(struct tty *tty) { tty_close(tty); - xfree(tty->ccolour); + free(tty->ccolour); if (tty->path != NULL) - xfree(tty->path); + free(tty->path); if (tty->termname != NULL) - xfree(tty->termname); + free(tty->termname); } void @@ -468,7 +468,7 @@ tty_force_cursor_colour(struct tty *tty, const char *ccolour) tty_putcode(tty, TTYC_CR); else tty_putcode_ptr1(tty, TTYC_CC, ccolour); - xfree(tty->ccolour); + free(tty->ccolour); tty->ccolour = xstrdup(ccolour); } @@ -1099,7 +1099,7 @@ tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx) b64_ntop(ctx->ptr, ctx->num, buf, off); tty_putcode_ptr2(tty, TTYC_MS, "", buf); - xfree(buf); + free(buf); } void diff --git a/window-choose.c b/window-choose.c index ed951661..58ac80ee 100644 --- a/window-choose.c +++ b/window-choose.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "tmux.h" @@ -152,12 +153,12 @@ window_choose_free(struct window_pane *wp) item = &ARRAY_ITEM(&data->list, i); if (data->freefn != NULL && item->wcd != NULL) data->freefn(item->wcd); - xfree(item->name); + free(item->name); } ARRAY_FREE(&data->list); screen_free(&data->screen); - xfree(data); + free(data); } void @@ -493,7 +494,7 @@ window_choose_ctx(struct window_choose_data *cdata) if (cause != NULL) { *cause = toupper((u_char) *cause); status_message_set(cdata->client, "%s", cause); - xfree(cause); + free(cause); } return; } @@ -544,7 +545,7 @@ window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx, xasprintf(&action_data, "%s:%d", s->name, wl->idx); wcd->command = cmd_template_replace(action, action_data, 1); - xfree(action_data); + free(action_data); wcd->idx = wl->idx; wcd->ft_template = xstrdup(template); diff --git a/window-clock.c b/window-clock.c index 64980df0..b6dc87e9 100644 --- a/window-clock.c +++ b/window-clock.c @@ -18,6 +18,7 @@ #include +#include #include #include @@ -69,7 +70,7 @@ window_clock_free(struct window_pane *wp) struct window_clock_mode_data *data = wp->modedata; screen_free(&data->screen); - xfree(data); + free(data); } void diff --git a/window-copy.c b/window-copy.c index cbd0bb6a..089974f1 100644 --- a/window-copy.c +++ b/window-copy.c @@ -240,17 +240,16 @@ window_copy_free(struct window_pane *wp) if (wp->fd != -1) bufferevent_enable(wp->event, EV_READ|EV_WRITE); - if (data->searchstr != NULL) - xfree(data->searchstr); - xfree(data->inputstr); + free(data->searchstr); + free(data->inputstr); if (data->backing != &wp->base) { screen_free(data->backing); - xfree(data->backing); + free(data->backing); } screen_free(&data->screen); - xfree(data); + free(data); } void @@ -1379,7 +1378,7 @@ window_copy_copy_selection(struct window_pane *wp, int idx) /* Don't bother if no data. */ if (off == 0) { - xfree(buf); + free(buf); return; } off--; /* remove final \n */ diff --git a/window.c b/window.c index cf13c906..cf738a1d 100644 --- a/window.c +++ b/window.c @@ -179,9 +179,8 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl) struct window *w = wl->window; RB_REMOVE(winlinks, wwl, wl); - if (wl->status_text != NULL) - xfree(wl->status_text); - xfree(wl); + free(wl->status_text); + free(wl); if (w != NULL) { if (w->references == 0) @@ -359,16 +358,14 @@ window_destroy(struct window *w) window_destroy_panes(w); - if (w->name != NULL) - xfree(w->name); - xfree(w); + free(w->name); + free(w); } void window_set_name(struct window *w, const char *new_name) { - if (w->name != NULL) - xfree(w->name); + free(w->name); w->name = xstrdup(new_name); notify_window_renamed(w); } @@ -671,13 +668,10 @@ window_pane_destroy(struct window_pane *wp) RB_REMOVE(window_pane_tree, &all_window_panes, wp); - if (wp->cwd != NULL) - xfree(wp->cwd); - if (wp->shell != NULL) - xfree(wp->shell); - if (wp->cmd != NULL) - xfree(wp->cmd); - xfree(wp); + free(wp->cwd); + free(wp->shell); + free(wp->cmd); + free(wp); } int @@ -694,18 +688,15 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, close(wp->fd); } if (cmd != NULL) { - if (wp->cmd != NULL) - xfree(wp->cmd); + free(wp->cmd); wp->cmd = xstrdup(cmd); } if (shell != NULL) { - if (wp->shell != NULL) - xfree(wp->shell); + free(wp->shell); wp->shell = xstrdup(shell); } if (cwd != NULL) { - if (wp->cwd != NULL) - xfree(wp->cwd); + free(wp->cwd); wp->cwd = xstrdup(cwd); } @@ -1048,10 +1039,10 @@ window_pane_search(struct window_pane *wp, const char *searchstr, u_int *lineno) *lineno = i; break; } - xfree(line); + free(line); } - xfree(newsearchstr); + free(newsearchstr); return (msg); } diff --git a/xmalloc.c b/xmalloc.c index 43b0080d..cb734edc 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -83,14 +83,6 @@ xrealloc(void *oldptr, size_t nmemb, size_t size) return (newptr); } -void -xfree(void *ptr) -{ - if (ptr == NULL) - fatalx("null pointer"); - free(ptr); -} - int printflike2 xasprintf(char **ret, const char *fmt, ...) {