mirror of
https://github.com/swaywm/sway.git
synced 2025-11-06 13:29:50 -05:00
Use statically allocated text buffer
This commit is contained in:
parent
c91adbd188
commit
849c3515ab
2 changed files with 5 additions and 7 deletions
|
|
@ -36,15 +36,15 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
|
|||
}
|
||||
|
||||
// set bar id
|
||||
int i;
|
||||
for (i = 0; i < config->bars->length; ++i) {
|
||||
for (int i = 0; i < config->bars->length; ++i) {
|
||||
if (bar == config->bars->items[i]) {
|
||||
const int len = 5 + numlen(i); // "bar-" + i + \0
|
||||
bar->id = malloc(len * sizeof(char));
|
||||
if (bar->id) {
|
||||
snprintf(bar->id, len, "bar-%d", i);
|
||||
} else {
|
||||
return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar ID");
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"bar", "Unable to allocate bar ID");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue