Skip to content

Commit a432fcd

Browse files
author
Tiago Cunha
committed
Sync OpenBSD patchset 1150:
xfree is not particularly helpful, remove it. From Thomas Adam.
1 parent 06d27e9 commit a432fcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+330
-360
lines changed

arguments.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,14 @@ args_parse(const char *template, int argc, char **argv)
6868
if (opt < 0 || opt >= SCHAR_MAX)
6969
continue;
7070
if (opt == '?' || (ptr = strchr(template, opt)) == NULL) {
71-
xfree(args->flags);
72-
xfree(args);
71+
free(args->flags);
72+
free(args);
7373
return (NULL);
7474
}
7575

7676
bit_set(args->flags, opt);
7777
if (ptr[1] == ':') {
78-
if (args->values[opt] != NULL)
79-
xfree(args->values[opt]);
78+
free(args->values[opt]);
8079
args->values[opt] = xstrdup(optarg);
8180
}
8281
}
@@ -97,13 +96,11 @@ args_free(struct args *args)
9796

9897
cmd_free_argv(args->argc, args->argv);
9998

100-
for (i = 0; i < SCHAR_MAX; i++) {
101-
if (args->values[i] != NULL)
102-
xfree(args->values[i]);
103-
}
99+
for (i = 0; i < SCHAR_MAX; i++)
100+
free(args->values[i]);
104101

105-
xfree(args->flags);
106-
xfree(args);
102+
free(args->flags);
103+
free(args);
107104
}
108105

109106
/* Print a set of arguments. */
@@ -182,8 +179,7 @@ args_has(struct args *args, u_char ch)
182179
void
183180
args_set(struct args *args, u_char ch, const char *value)
184181
{
185-
if (args->values[ch] != NULL)
186-
xfree(args->values[ch]);
182+
free(args->values[ch]);
187183
if (value != NULL)
188184
args->values[ch] = xstrdup(value);
189185
else

array.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,12 @@
109109
} while (0)
110110

111111
#define ARRAY_FREE(a) do { \
112-
if ((a)->list != NULL) \
113-
xfree((a)->list); \
112+
free((a)->list); \
114113
ARRAY_INIT(a); \
115114
} while (0)
116115
#define ARRAY_FREEALL(a) do { \
117116
ARRAY_FREE(a); \
118-
xfree(a); \
117+
free(a); \
119118
} while (0)
120119

121120
#endif

cfg.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <errno.h>
2323
#include <stdio.h>
24+
#include <stdlib.h>
2425
#include <string.h>
2526

2627
#include "tmux.h"
@@ -117,14 +118,14 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
117118
line = NULL;
118119

119120
if (cmd_string_parse(buf, &cmdlist, &cause) != 0) {
120-
xfree(buf);
121+
free(buf);
121122
if (cause == NULL)
122123
continue;
123124
cfg_add_cause(causes, "%s: %u: %s", path, n, cause);
124-
xfree(cause);
125+
free(cause);
125126
continue;
126127
} else
127-
xfree(buf);
128+
free(buf);
128129
if (cmdlist == NULL)
129130
continue;
130131
cfg_cause = NULL;
@@ -150,13 +151,13 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
150151
if (cfg_cause != NULL) {
151152
cfg_add_cause(
152153
causes, "%s: %d: %s", path, n, cfg_cause);
153-
xfree(cfg_cause);
154+
free(cfg_cause);
154155
}
155156
}
156157
if (line != NULL) {
157158
cfg_add_cause(causes,
158159
"%s: %d: line continuation at end of file", path, n);
159-
xfree(line);
160+
free(line);
160161
}
161162
fclose(f);
162163

client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ client_connect(char *path, int start_server)
122122
if (unlink(path) != 0 && errno != ENOENT)
123123
return (-1);
124124
fd = server_start(lockfd, lockfile);
125-
xfree(lockfile);
125+
free(lockfile);
126126
close(lockfd);
127127
}
128128

cmd-attach-session.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <sys/types.h>
2020

21+
#include <stdlib.h>
22+
2123
#include "tmux.h"
2224

2325
/*
@@ -81,7 +83,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
8183
} else {
8284
if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
8385
ctx->error(ctx, "open terminal failed: %s", cause);
84-
xfree(cause);
86+
free(cause);
8587
return (-1);
8688
}
8789

cmd-bind-key.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <sys/types.h>
2020

21+
#include <stdlib.h>
2122
#include <string.h>
2223

2324
#include "tmux.h"
@@ -74,7 +75,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
7475
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause);
7576
if (cmdlist == NULL) {
7677
ctx->error(ctx, "%s", cause);
77-
xfree(cause);
78+
free(cause);
7879
return (-1);
7980
}
8081

cmd-break-pane.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
8181
w->active = wp;
8282
name = default_window_name(w);
8383
window_set_name(w, name);
84-
xfree(name);
84+
free(name);
8585
layout_init(w);
8686

8787
base_idx = options_get_number(&s->options, "base-index");
@@ -106,7 +106,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
106106

107107
cp = format_expand(ft, template);
108108
ctx->print(ctx, "%s", cp);
109-
xfree(cp);
109+
free(cp);
110110

111111
format_free(ft);
112112
}

cmd-capture-pane.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
6262
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
6363
if (cause != NULL) {
6464
top = gd->hsize;
65-
xfree(cause);
65+
free(cause);
6666
} else if (n < 0 && (u_int) -n > gd->hsize)
6767
top = 0;
6868
else
@@ -73,7 +73,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
7373
n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause);
7474
if (cause != NULL) {
7575
bottom = gd->hsize + gd->sy - 1;
76-
xfree(cause);
76+
free(cause);
7777
} else if (n < 0 && (u_int) -n > gd->hsize)
7878
bottom = 0;
7979
else
@@ -96,7 +96,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
9696
len += linelen;
9797
buf[len++] = '\n';
9898

99-
xfree(line);
99+
free(line);
100100
}
101101

102102
limit = options_get_number(&global_options, "buffer-limit");
@@ -109,14 +109,14 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
109109
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
110110
if (cause != NULL) {
111111
ctx->error(ctx, "buffer %s", cause);
112-
xfree(buf);
113-
xfree(cause);
112+
free(buf);
113+
free(cause);
114114
return (-1);
115115
}
116116

117117
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
118118
ctx->error(ctx, "no buffer %d", buffer);
119-
xfree(buf);
119+
free(buf);
120120
return (-1);
121121
}
122122

cmd-choose-buffer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/types.h>
2020

2121
#include <ctype.h>
22+
#include <stdlib.h>
2223

2324
#include "tmux.h"
2425

@@ -86,11 +87,11 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
8687

8788
xasprintf(&action_data, "%u", idx - 1);
8889
cdata->command = cmd_template_replace(action, action_data, 1);
89-
xfree(action_data);
90+
free(action_data);
9091

9192
window_choose_add(wl->window->active, cdata);
9293
}
93-
xfree(action);
94+
free(action);
9495

9596
window_choose_ready(wl->window->active,
9697
0, cmd_choose_buffer_callback, cmd_choose_buffer_free);
@@ -119,7 +120,7 @@ cmd_choose_buffer_free(struct window_choose_data *data)
119120

120121
cdata->client->references--;
121122

122-
xfree(cdata->command);
123-
xfree(cdata->ft_template);
124-
xfree(cdata);
123+
free(cdata->command);
124+
free(cdata->ft_template);
125+
free(cdata);
125126
}

cmd-choose-client.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/types.h>
2020

2121
#include <ctype.h>
22+
#include <stdlib.h>
2223

2324
#include "tmux.h"
2425

@@ -98,7 +99,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
9899

99100
window_choose_add(wl->window->active, cdata);
100101
}
101-
xfree(action);
102+
free(action);
102103

103104
window_choose_ready(wl->window->active,
104105
cur, cmd_choose_client_callback, cmd_choose_client_free);
@@ -133,8 +134,8 @@ cmd_choose_client_free(struct window_choose_data *cdata)
133134

134135
cdata->client->references--;
135136

136-
xfree(cdata->ft_template);
137-
xfree(cdata->command);
137+
free(cdata->ft_template);
138+
free(cdata->command);
138139
format_free(cdata->ft);
139-
xfree(cdata);
140+
free(cdata);
140141
}

cmd-choose-tree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/types.h>
2020

2121
#include <ctype.h>
22+
#include <stdlib.h>
2223

2324
#include <string.h>
2425

@@ -206,7 +207,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
206207
ctx, s2, wm, final_win_template,
207208
final_win_action, idx_ses);
208209

209-
xfree(final_win_action);
210+
free(final_win_action);
210211
}
211212
/*
212213
* If we're just drawing windows, don't consider moving on to
@@ -215,8 +216,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
215216
if (wflag && !sflag)
216217
break;
217218
}
218-
if (final_win_template != NULL)
219-
xfree(final_win_template);
219+
free(final_win_template);
220220

221221
window_choose_ready(wl->window->active, cur_win,
222222
cmd_choose_tree_callback, cmd_choose_tree_free);
@@ -242,10 +242,10 @@ cmd_choose_tree_free(struct window_choose_data *cdata)
242242
cdata->session->references--;
243243
cdata->client->references--;
244244

245-
xfree(cdata->ft_template);
246-
xfree(cdata->command);
245+
free(cdata->ft_template);
246+
free(cdata->command);
247247
format_free(cdata->ft);
248-
xfree(cdata);
248+
free(cdata);
249249

250250
}
251251

cmd-command-prompt.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/types.h>
2020

2121
#include <ctype.h>
22+
#include <stdlib.h>
2223
#include <string.h>
2324
#include <time.h>
2425

@@ -138,7 +139,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
138139

139140
status_prompt_set(c, prompt, input, cmd_command_prompt_callback,
140141
cmd_command_prompt_free, cdata, 0);
141-
xfree(prompt);
142+
free(prompt);
142143

143144
return (0);
144145
}
@@ -157,7 +158,7 @@ cmd_command_prompt_callback(void *data, const char *s)
157158
return (0);
158159

159160
new_template = cmd_template_replace(cdata->template, s, cdata->idx);
160-
xfree(cdata->template);
161+
free(cdata->template);
161162
cdata->template = new_template;
162163

163164
/*
@@ -169,7 +170,7 @@ cmd_command_prompt_callback(void *data, const char *s)
169170
input = strsep(&cdata->next_input, ",");
170171
status_prompt_update(c, prompt, input);
171172

172-
xfree(prompt);
173+
free(prompt);
173174
cdata->idx++;
174175
return (1);
175176
}
@@ -178,7 +179,7 @@ cmd_command_prompt_callback(void *data, const char *s)
178179
if (cause != NULL) {
179180
*cause = toupper((u_char) *cause);
180181
status_message_set(c, "%s", cause);
181-
xfree(cause);
182+
free(cause);
182183
}
183184
return (0);
184185
}
@@ -205,11 +206,8 @@ cmd_command_prompt_free(void *data)
205206
{
206207
struct cmd_command_prompt_cdata *cdata = data;
207208

208-
if (cdata->inputs != NULL)
209-
xfree(cdata->inputs);
210-
if (cdata->prompts != NULL)
211-
xfree(cdata->prompts);
212-
if (cdata->template != NULL)
213-
xfree(cdata->template);
214-
xfree(cdata);
209+
free(cdata->inputs);
210+
free(cdata->prompts);
211+
free(cdata->template);
212+
free(cdata);
215213
}

0 commit comments

Comments
 (0)