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/config/output.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/config/output.c')
-rw-r--r-- | sway/config/output.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 45d2441b..6fb29ded 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -162,13 +162,10 @@ static void merge_id_on_name(struct output_config *oc) { | |||
162 | char id[128]; | 162 | char id[128]; |
163 | output_get_identifier(id, sizeof(id), output); | 163 | output_get_identifier(id, sizeof(id), output); |
164 | 164 | ||
165 | size_t size = snprintf(NULL, 0, "%s on %s", id, name) + 1; | 165 | char *id_on_name = format_str("%s on %s", id, name); |
166 | char *id_on_name = malloc(size); | ||
167 | if (!id_on_name) { | 166 | if (!id_on_name) { |
168 | sway_log(SWAY_ERROR, "Failed to allocate id on name string"); | ||
169 | return; | 167 | return; |
170 | } | 168 | } |
171 | snprintf(id_on_name, size, "%s on %s", id, name); | ||
172 | 169 | ||
173 | int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); | 170 | int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); |
174 | if (i >= 0) { | 171 | if (i >= 0) { |
@@ -633,9 +630,7 @@ static struct output_config *get_output_config(char *identifier, | |||
633 | struct output_config *oc_name = NULL; | 630 | struct output_config *oc_name = NULL; |
634 | struct output_config *oc_id = NULL; | 631 | struct output_config *oc_id = NULL; |
635 | 632 | ||
636 | size_t length = snprintf(NULL, 0, "%s on %s", identifier, name) + 1; | 633 | char *id_on_name = format_str("%s on %s", identifier, name); |
637 | char *id_on_name = malloc(length); | ||
638 | snprintf(id_on_name, length, "%s on %s", identifier, name); | ||
639 | int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); | 634 | int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); |
640 | if (i >= 0) { | 635 | if (i >= 0) { |
641 | oc_id_on_name = config->output_configs->items[i]; | 636 | oc_id_on_name = config->output_configs->items[i]; |