diff options
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 @@ -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 @@ -21,6 +21,7 @@ #include <errno.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #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); @@ -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 <sys/types.h> +#include <stdlib.h> + #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 <sys/types.h> +#include <stdlib.h> #include <string.h> #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 <sys/types.h> #include <ctype.h> +#include <stdlib.h> #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 <sys/types.h> #include <ctype.h> +#include <stdlib.h> #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 <sys/types.h> #include <ctype.h> +#include <stdlib.h> #include <string.h> @@ -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 <sys/types.h> #include <ctype.h> +#include <stdlib.h> #include <string.h> #include <time.h> @@ -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 <ctype.h> +#include <stdlib.h> #include <string.h> #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 <sys/types.h> +#include <stdlib.h> #include <time.h> #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 <sys/types.h> #include <fnmatch.h> +#include <stdlib.h> #include <string.h> #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); } d |