diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 21:54:08 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | 849c3515abff7033dbd4723fd7328cb07af74222 (patch) | |
tree | 879dde1271572fdfe86dc0f33944100ba61a959e /sway/commands/bar.c | |
parent | Fix failure to rearrange output in some cases (diff) | |
download | sway-849c3515abff7033dbd4723fd7328cb07af74222.tar.gz sway-849c3515abff7033dbd4723fd7328cb07af74222.tar.zst sway-849c3515abff7033dbd4723fd7328cb07af74222.zip |
Use statically allocated text buffer
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r-- | sway/commands/bar.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c index 548106b3..ff111163 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c | |||
@@ -36,15 +36,15 @@ struct cmd_results *cmd_bar(int argc, char **argv) { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | // set bar id | 38 | // set bar id |
39 | int i; | 39 | for (int i = 0; i < config->bars->length; ++i) { |
40 | for (i = 0; i < config->bars->length; ++i) { | ||
41 | if (bar == config->bars->items[i]) { | 40 | if (bar == config->bars->items[i]) { |
42 | const int len = 5 + numlen(i); // "bar-" + i + \0 | 41 | const int len = 5 + numlen(i); // "bar-" + i + \0 |
43 | bar->id = malloc(len * sizeof(char)); | 42 | bar->id = malloc(len * sizeof(char)); |
44 | if (bar->id) { | 43 | if (bar->id) { |
45 | snprintf(bar->id, len, "bar-%d", i); | 44 | snprintf(bar->id, len, "bar-%d", i); |
46 | } else { | 45 | } else { |
47 | return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar ID"); | 46 | return cmd_results_new(CMD_FAILURE, |
47 | "bar", "Unable to allocate bar ID"); | ||
48 | } | 48 | } |
49 | break; | 49 | break; |
50 | } | 50 | } |