diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-07-10 11:53:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-07-10 11:53:02 +0000 |
commit | 0ed606e0c38d62777110f204c4bccdfd890a34ea (patch) | |
tree | 48bd8518754ed4e6522fdbc3be9885313ad0a227 /usr.bin | |
parent | 8a386e18f9ebed887bd888ffd5bede8694b2ef62 (diff) |
xfree is not particularly helpful, remove it. From Thomas Adam.
Diffstat (limited to 'usr.bin')
73 files changed, 402 insertions, 433 deletions
diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c index f41edec9871..cb4d62a12dc 100644 --- a/usr.bin/tmux/arguments.c +++ b/usr.bin/tmux/arguments.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arguments.c,v 1.3 2011/07/09 01:36:42 nicm Exp $ */ +/* $OpenBSD: arguments.c,v 1.4 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/array.h b/usr.bin/tmux/array.h index 3edc718b359..e4a9d690bfd 100644 --- a/usr.bin/tmux/array.h +++ b/usr.bin/tmux/array.h @@ -1,4 +1,4 @@ -/* $OpenBSD: array.h,v 1.5 2010/06/05 16:32:22 nicm Exp $ */ +/* $OpenBSD: array.h,v 1.6 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index 6f935622662..c0dbb9ed0ec 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.14 2012/05/17 21:21:31 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.15 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index 435cdc52cb1..c34c8ff9915 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.57 2012/06/18 13:34:56 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.58 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c index 759f4df4e9b..d7f36bf01a3 100644 --- a/usr.bin/tmux/cmd-attach-session.c +++ b/usr.bin/tmux/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-attach-session.c,v 1.20 2012/05/22 10:56:48 nicm Exp $ */ +/* $OpenBSD: cmd-attach-session.c,v 1.21 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-bind-key.c b/usr.bin/tmux/cmd-bind-key.c index a01a95025b2..18c4a4bb9a1 100644 --- a/usr.bin/tmux/cmd-bind-key.c +++ b/usr.bin/tmux/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-bind-key.c,v 1.12 2012/01/21 11:12:13 nicm Exp $ */ +/* $OpenBSD: cmd-bind-key.c,v 1.13 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c index 51d23e8eeb1..d146dd1d4f9 100644 --- a/usr.bin/tmux/cmd-break-pane.c +++ b/usr.bin/tmux/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-break-pane.c,v 1.14 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-break-pane.c,v 1.15 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-capture-pane.c b/usr.bin/tmux/cmd-capture-pane.c index c3ba66faf13..5c2f733e888 100644 --- a/usr.bin/tmux/cmd-capture-pane.c +++ b/usr.bin/tmux/cmd-capture-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-capture-pane.c,v 1.10 2011/12/27 13:46:26 nicm Exp $ */ +/* $OpenBSD: cmd-capture-pane.c,v 1.11 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-choose-buffer.c b/usr.bin/tmux/cmd-choose-buffer.c index a41247fb0d2..06015163f73 100644 --- a/usr.bin/tmux/cmd-choose-buffer.c +++ b/usr.bin/tmux/cmd-choose-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-buffer.c,v 1.7 2012/06/25 14:27:25 nicm Exp $ */ +/* $OpenBSD: cmd-choose-buffer.c,v 1.8 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-choose-client.c b/usr.bin/tmux/cmd-choose-client.c index 27b2d305bc2..285d7269f86 100644 --- a/usr.bin/tmux/cmd-choose-client.c +++ b/usr.bin/tmux/cmd-choose-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-client.c,v 1.9 2012/06/25 14:27:25 nicm Exp $ */ +/* $OpenBSD: cmd-choose-client.c,v 1.10 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c index 2a39c86023b..86f0f748298 100644 --- a/usr.bin/tmux/cmd-choose-tree.c +++ b/usr.bin/tmux/cmd-choose-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-tree.c,v 1.2 2012/07/09 07:08:03 nicm Exp $ */ +/* $OpenBSD: cmd-choose-tree.c,v 1.3 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2012 Thomas Adam <thomas@xteddy.org> @@ -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/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c index 7db34aafb1f..bad8f00b579 100644 --- a/usr.bin/tmux/cmd-command-prompt.c +++ b/usr.bin/tmux/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-command-prompt.c,v 1.19 2011/07/08 06:37:57 nicm Exp $ */ +/* $OpenBSD: cmd-command-prompt.c,v 1.20 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-confirm-before.c b/usr.bin/tmux/cmd-confirm-before.c index 160cbd4e0d1..3438ddf8052 100644 --- a/usr.bin/tmux/cmd-confirm-before.c +++ b/usr.bin/tmux/cmd-confirm-before.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-confirm-before.c,v 1.12 2011/07/08 06:37:57 nicm Exp $ */ +/* $OpenBSD: cmd-confirm-before.c,v 1.13 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -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/usr.bin/tmux/cmd-delete-buffer.c b/usr.bin/tmux/cmd-delete-buffer.c index 7834839f047..a4efc2a8dcb 100644 --- a/usr.bin/tmux/cmd-delete-buffer.c +++ b/usr.bin/tmux/cmd-delete-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-delete-buffer.c,v 1.6 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-delete-buffer.c,v 1.7 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index 76183003f74..a366a20df05 100644 --- a/usr.bin/tmux/cmd-display-message.c +++ b/usr.bin/tmux/cmd-display-message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-message.c,v 1.13 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.14 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -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/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c index 76e7456d1d6..cf46ec63f40 100644 --- a/usr.bin/tmux/cmd-find-window.c +++ b/usr.bin/tmux/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find-window.c,v 1.15 2012/06/25 14:08:55 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.16 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); } diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c index 93c75f68705..abb27d3a7b3 100644 --- a/usr.bin/tmux/cmd-if-shell.c +++ b/usr.bin/tmux/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-if-shell.c,v 1.14 2011/10/27 22:40:15 nicm Exp $ */ +/* $OpenBSD: cmd-if-shell.c,v 1.15 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-join-pane.c b/usr.bin/tmux/cmd-join-pane.c index 6007a783fa7..ba48e593534 100644 --- a/usr.bin/tmux/cmd-join-pane.c +++ b/usr.bin/tmux/cmd-join-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-join-pane.c,v 1.10 2012/04/01 20:53:47 nicm Exp $ */ +/* $OpenBSD: cmd-join-pane.c,v 1.11 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2011 George Nachman <tmux@georgester.com> @@ -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/usr.bin/tmux/cmd-link-window.c b/usr.bin/tmux/cmd-link-window.c index 8d639fbd470..cfadf360855 100644 --- a/usr.bin/tmux/cmd-link-window.c +++ b/usr.bin/tmux/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-link-window.c,v 1.10 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-link-window.c,v 1.11 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-list-buffers.c b/usr.bin/tmux/cmd-list-buffers.c index 9e1eefb5abc..741b97af13d 100644 --- a/usr.bin/tmux/cmd-list-buffers.c +++ b/usr.bin/tmux/cmd-list-buffers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-buffers.c,v 1.12 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-list-buffers.c,v 1.13 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c index 542557f2bb2..e7f173ba51d 100644 --- a/usr.bin/tmux/cmd-list-clients.c +++ b/usr.bin/tmux/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-clients.c,v 1.10 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-list-clients.c,v 1.11 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include <time.h> @@ -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/usr.bin/tmux/cmd-list-panes.c b/usr.bin/tmux/cmd-list-panes.c index 10ffd86234d..073270c836c 100644 --- a/usr.bin/tmux/cmd-list-panes.c +++ b/usr.bin/tmux/cmd-list-panes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-panes.c,v 1.13 2011/11/15 23:21:52 nicm Exp $ */ +/* $OpenBSD: cmd-list-panes.c,v 1.14 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/cmd-list-sessions.c b/usr.bin/tmux/cmd-list-sessions.c index c094a37cdc7..2c5ab32486e 100644 --- a/usr.bin/tmux/cmd-list-sessions.c +++ b/usr.bin/tmux/cmd-list-sessions.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-sessions.c,v 1.11 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-list-sessions.c,v 1.12 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include <time.h> @@ -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/usr.bin/tmux/cmd-list-windows.c b/usr.bin/tmux/cmd-list-windows.c index 0e41945a986..016eb22b802 100644 --- a/usr.bin/tmux/cmd-list-windows.c +++ b/usr.bin/tmux/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-windows.c,v 1.21 2012/05/28 08:00:46 nicm Exp $ */ +/* $OpenBSD: cmd-list-windows.c,v 1.22 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/cmd-list.c b/usr.bin/tmux/cmd-list.c index 82188532644..8b586b08ac9 100644 --- a/usr.bin/tmux/cmd-list.c +++ b/usr.bin/tmux/cmd-list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list.c,v 1.7 2012/06/18 13:16:42 nicm Exp $ */ +/* $OpenBSD: cmd-list.c,v 1.8 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c index 60eb18ea76d..8a77481fe37 100644 --- a/usr.bin/tmux/cmd-load-buffer.c +++ b/usr.bin/tmux/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.20 2012/05/21 18:27:42 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.21 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -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/usr.bin/tmux/cmd-move-window.c b/usr.bin/tmux/cmd-move-window.c index 4da31af35d6..c296260cab6 100644 --- a/usr.bin/tmux/cmd-move-window.c +++ b/usr.bin/tmux/cmd-move-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-move-window.c,v 1.12 2012/05/13 07:33:31 nicm Exp $ */ +/* $OpenBSD: cmd-move-window.c,v 1.13 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index b461eddef15..244d8a033cd 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.43 2012/05/22 10:56:48 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.44 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c index a267b405984..484609246e8 100644 --- a/usr.bin/tmux/cmd-new-window.c +++ b/usr.bin/tmux/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-window.c,v 1.24 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-new-window.c,v 1.25 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-paste-buffer.c b/usr.bin/tmux/cmd-paste-buffer.c index e2fe0129d3d..db76f3aabd8 100644 --- a/usr.bin/tmux/cmd-paste-buffer.c +++ b/usr.bin/tmux/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-paste-buffer.c,v 1.17 2012/03/03 09:43:22 nicm Exp $ */ +/* $OpenBSD: cmd-paste-buffer.c,v 1.18 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-rename-session.c b/usr.bin/tmux/cmd-rename-session.c index 6e79823e6e7..dd88ba8d296 100644 --- a/usr.bin/tmux/cmd-rename-session.c +++ b/usr.bin/tmux/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rename-session.c,v 1.11 2012/03/17 22:35:09 nicm Exp $ */ +/* $OpenBSD: cmd-rename-session.c,v 1.12 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-respawn-pane.c b/usr.bin/tmux/cmd-respawn-pane.c index 86b5fb05fac..c6f9c06d8a5 100644 --- a/usr.bin/tmux/cmd-respawn-pane.c +++ b/usr.bin/tmux/cmd-respawn-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-respawn-pane.c,v 1.5 2012/03/17 22:34:12 nicm Exp $ */ +/* $OpenBSD: cmd-respawn-pane.c,v 1.6 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/cmd-respawn-window.c b/usr.bin/tmux/cmd-respawn-window.c index 6cc4b3e3b6c..520db456b4f 100644 --- a/usr.bin/tmux/cmd-respawn-window.c +++ b/usr.bin/tmux/cmd-respawn-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-respawn-window.c,v 1.14 2011/07/04 13:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-respawn-window.c,v 1.15 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/cmd-run-shell.c b/usr.bin/tmux/cmd-run-shell.c index 7e08e4ce779..8ca4d08ae2a 100644 --- a/usr.bin/tmux/cmd-run-shell.c +++ b/usr.bin/tmux/cmd-run-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-run-shell.c,v 1.11 2011/01/26 01:54:56 nicm Exp $ */ +/* $OpenBSD: cmd-run-shell.c,v 1.12 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c index 05675b3bf7b..d71173ecd91 100644 --- a/usr.bin/tmux/cmd-save-buffer.c +++ b/usr.bin/tmux/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-save-buffer.c,v 1.14 2012/05/21 18:27:42 nicm Exp $ */ +/* $OpenBSD: cmd-save-buffer.c,v 1.15 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -20,6 +20,7 @@ #include <sys/stat.h> #include <errno.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-set-buffer.c b/usr.bin/tmux/cmd-set-buffer.c index 64ca74c23f5..c1bff82fb1e 100644 --- a/usr.bin/tmux/cmd-set-buffer.c +++ b/usr.bin/tmux/cmd-set-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-buffer.c,v 1.10 2011/10/23 00:49:25 nicm Exp $ */ +/* $OpenBSD: cmd-set-buffer.c,v 1.11 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 4babd2a3796..265f12adefd 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.55 2012/04/08 06:47:26 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.56 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-show-buffer.c b/usr.bin/tmux/cmd-show-buffer.c index e433b0e3cf3..033e7c9a61c 100644 --- a/usr.bin/tmux/cmd-show-buffer.c +++ b/usr.bin/tmux/cmd-show-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-buffer.c,v 1.12 2011/10/23 00:49:25 nicm Exp $ */ +/* $OpenBSD: cmd-show-buffer.c,v 1.13 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <vis.h> #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/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 6d04a508e6c..2596df4fcea 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.11 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.12 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -18,6 +18,8 @@ #include <sys/types.h> +#include <stdlib.h> + #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/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index 3f2cd2fd438..b173d600568 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.33 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.34 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-string.c b/usr.bin/tmux/cmd-string.c index 4b0c962e9e3..97500bd28ca 100644 --- a/usr.bin/tmux/cmd-string.c +++ b/usr.bin/tmux/cmd-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-string.c,v 1.15 2010/12/13 22:53:14 nicm Exp $ */ +/* $OpenBSD: cmd-string.c,v 1.16 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/cmd-unbind-key.c b/usr.bin/tmux/cmd-unbind-key.c index bce7fdafaf8..c474110bb2e 100644 --- a/usr.bin/tmux/cmd-unbind-key.c +++ b/usr.bin/tmux/cmd-unbind-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-unbind-key.c,v 1.13 2012/05/05 17:40:47 nicm Exp $ */ +/* $OpenBSD: cmd-unbind-key.c,v 1.14 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,8 @@ #include <sys/types.h> +#include <stdlib.h> + #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/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index e3b89eb1d55..1316b30c894 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.67 2012/07/08 16:04:38 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.68 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/control.c b/usr.bin/tmux/control.c index 88d97dcdf9b..d5e45b1e2ff 100644 --- a/usr.bin/tmux/control.c +++ b/usr.bin/tmux/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.1 2012/06/18 13:16:42 nicm Exp $ */ +/* $OpenBSD: control.c,v 1.2 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net> @@ -20,6 +20,7 @@ #include <sys/types.h> #include <event.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/environ.c b/usr.bin/tmux/environ.c index 16b7f19a3e1..7cbfa3566f1 100644 --- a/usr.bin/tmux/environ.c +++ b/usr.bin/tmux/environ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: environ.c,v 1.4 2010/04/04 19:02:09 nicm Exp $ */ +/* $OpenBSD: environ.c,v 1.5 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index fb9fffe51ab..dc7e6981e31 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.8 2012/05/22 11:35:37 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.9 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -20,6 +20,7 @@ #include <netdb.h> #include <stdarg.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> @@ -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/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 3c4cbe18c1a..77592dd9bec 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.19 2012/05/23 19:19:40 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.20 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c index 07018cb320e..6b78bd67264 100644 --- a/usr.bin/tmux/input-keys.c +++ b/usr.bin/tmux/input-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input-keys.c,v 1.25 2012/05/05 18:48:31 nicm Exp $ */ +/* $OpenBSD: input-keys.c,v 1.26 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index b1c13a32ba7..9d366b43220 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.52 2012/04/25 21:12:49 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.53 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index dab589e89f7..f812eec6d27 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.26 2012/01/29 02:22:11 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.27 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -21,6 +21,7 @@ #include <fcntl.h> #include <paths.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -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/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index ca6ee7786fb..9fd68432c20 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.32 2012/07/08 16:04:38 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.33 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c index 190d7e344aa..c7a519ff216 100644 --- a/usr.bin/tmux/layout.c +++ b/usr.bin/tmux/layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout.c,v 1.13 2012/04/01 21:07:35 nicm Exp $ */ +/* $OpenBSD: layout.c,v 1.14 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/names.c b/usr.bin/tmux/names.c index 64fc973137f..290946c94ab 100644 --- a/usr.bin/tmux/names.c +++ b/usr.bin/tmux/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.15 2012/04/11 07:45:30 nicm Exp $ */ +/* $OpenBSD: names.c,v 1.16 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -20,6 +20,7 @@ #include <ctype.h> #include <libgen.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -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/usr.bin/tmux/options.c b/usr.bin/tmux/options.c index d3458ddc2f0..54476b44736 100644 --- a/usr.bin/tmux/options.c +++ b/usr.bin/tmux/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.7 2012/01/21 11:12:13 nicm Exp $ */ +/* $OpenBSD: options.c,v 1.8 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <stdarg.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c index def59f83e18..2b0a0ac88a8 100644 --- a/usr.bin/tmux/paste.c +++ b/usr.bin/tmux/paste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paste.c,v 1.11 2011/03/28 19:44:31 nicm Exp $ */ +/* $OpenBSD: paste.c,v 1.12 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sys/time.h> +#include <stdlib.h> #include <string.h> #include <vis.h> @@ -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/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 16811758576..55808aa129d 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.55 2012/03/17 17:36:03 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.56 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c index efaddce086a..85732027c3e 100644 --- a/usr.bin/tmux/screen.c +++ b/usr.bin/tmux/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.22 2012/03/17 21:37:36 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.23 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index d0f098fed52..db8e357fcac 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.76 2012/06/20 12:55:55 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.77 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -23,6 +23,7 @@ #include <string.h> #include <time.h> #include <paths.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 3278961b32d..6eba98075cc 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.59 2012/06/18 13:16:42 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.60 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> @@ -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/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c index e6bcb69dd21..7086d0ec3ff 100644 --- a/usr.bin/tmux/server-window.c +++ b/usr.bin/tmux/server-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-window.c,v 1.25 2012/07/08 07:27:32 nicm Exp $ */ +/* $OpenBSD: server-window.c,v 1.26 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <event.h> +#include <stdlib.h> #include <unistd.h> #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/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index 2efe0f54d5e..1fcd54572b0 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.104 2012/04/11 06:16:14 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.105 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/session.c b/usr.bin/tmux/session.c index b458c399a84..1511ebf4169 100644 --- a/usr.bin/tmux/session.c +++ b/usr.bin/tmux/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.35 2012/07/08 07:27:32 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.36 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index a5df4e032f9..820ec58cda0 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.93 2012/07/09 09:55:57 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.94 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 6b6ed05b41c..7b436227319 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.111 2012/06/18 13:16:42 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.112 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 1a08ea2ba1f..0cbae415695 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.346 2012/07/08 16:04:38 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.347 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index b8012f0c041..3d7b1ec3c65 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.41 2012/05/22 14:32:28 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.42 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c index 3bd0e3a6ec8..1c86709f95d 100644 --- a/usr.bin/tmux/tty-term.c +++ b/usr.bin/tmux/tty-term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-term.c,v 1.28 2012/05/22 09:36:12 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.29 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 2ca1ea3c0ba..e665dcf7cf6 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.137 2012/06/20 12:55:55 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.138 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c index 1254f58407a..dc195ed4ce2 100644 --- a/usr.bin/tmux/window-choose.c +++ b/usr.bin/tmux/window-choose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-choose.c,v 1.20 2012/06/25 14:27:25 nicm Exp $ */ +/* $OpenBSD: window-choose.c,v 1.21 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <ctype.h> +#include <stdlib.h> #include <string.h> #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/usr.bin/tmux/window-clock.c b/usr.bin/tmux/window-clock.c index 4cecdd07d5a..97ac5c00cdf 100644 --- a/usr.bin/tmux/window-clock.c +++ b/usr.bin/tmux/window-clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-clock.c,v 1.6 2010/05/23 19:42:19 nicm Exp $ */ +/* $OpenBSD: window-clock.c,v 1.7 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include <time.h> @@ -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/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 825a568c50d..40c5fe0d903 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.80 2012/04/01 20:53:47 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.81 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index bcde5f13b9b..443661936b1 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.81 2012/07/08 07:27:32 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.82 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/xmalloc.c b/usr.bin/tmux/xmalloc.c index 797144e4015..6ef8afd47cd 100644 --- a/usr.bin/tmux/xmalloc.c +++ b/usr.bin/tmux/xmalloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.c,v 1.3 2009/10/26 21:42:04 deraadt Exp $ */ +/* $OpenBSD: xmalloc.c,v 1.4 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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, ...) { |