diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-28 16:43:05 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-04-14 18:34:54 +0200 |
commit | 08c1946d71039e583696842c3558b337aede1cbf (patch) | |
tree | 3873db2edfb31146bd6cd17dae63f068aef34f05 /sway/commands/bar.c | |
parent | common/gesture: use format_str() (diff) | |
download | sway-08c1946d71039e583696842c3558b337aede1cbf.tar.gz sway-08c1946d71039e583696842c3558b337aede1cbf.tar.zst sway-08c1946d71039e583696842c3558b337aede1cbf.zip |
Use format_str() throughout
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r-- | sway/commands/bar.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c index 8571d282..22756acb 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c | |||
@@ -73,12 +73,10 @@ struct cmd_results *cmd_bar(int argc, char **argv) { | |||
73 | } | 73 | } |
74 | ++argv; --argc; | 74 | ++argv; --argc; |
75 | } else if (config->reading && !config->current_bar) { | 75 | } else if (config->reading && !config->current_bar) { |
76 | int len = snprintf(NULL, 0, "bar-%d", config->bars->length) + 1; | 76 | id = format_str("bar-%d", config->bars->length); |
77 | id = malloc(len * sizeof(char)); | ||
78 | if (!id) { | 77 | if (!id) { |
79 | return cmd_results_new(CMD_FAILURE, "Unable to allocate bar id"); | 78 | return cmd_results_new(CMD_FAILURE, "Unable to allocate bar id"); |
80 | } | 79 | } |
81 | snprintf(id, len, "bar-%d", config->bars->length); | ||
82 | } else if (!config->reading && strcmp(argv[0], "mode") != 0 && | 80 | } else if (!config->reading && strcmp(argv[0], "mode") != 0 && |
83 | strcmp(argv[0], "hidden_state") != 0) { | 81 | strcmp(argv[0], "hidden_state") != 0) { |
84 | if (is_subcommand(argv[0])) { | 82 | if (is_subcommand(argv[0])) { |