diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2022-02-28 17:18:54 -0600 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2022-02-28 17:18:54 -0600 |
| commit | 38288c3916d3d9f33771c220ae307d32e8a208e8 (patch) | |
| tree | 46ebdb918f86d163259520d67d6f7928b8634d40 /swaynag | |
| parent | c2336edeb454b871b33c6408543ad9635105045c (diff) | |
swaynag: statically allocate button_close, and move declaration
Every swaynag has a close button, so it doesn't make sense to
allocate it dynamically. The declaration is moved later to when
it is actually needed.
Diffstat (limited to 'swaynag')
| -rw-r--r-- | swaynag/main.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/swaynag/main.c b/swaynag/main.c index 112a8b2f..f7bf8a20 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -30,16 +30,6 @@ int main(int argc, char **argv) { wl_list_init(&swaynag.outputs); wl_list_init(&swaynag.seats); - struct swaynag_button *button_close = - calloc(sizeof(struct swaynag_button), 1); - if (!button_close) { - perror("calloc"); - return EXIT_FAILURE; - } - button_close->text = strdup("X"); - button_close->type = SWAYNAG_ACTION_DISMISS; - list_add(swaynag.buttons, button_close); - char *config_path = NULL; bool debug = false; int launch_status = swaynag_parse_options(argc, argv, NULL, NULL, NULL, @@ -100,6 +90,11 @@ int main(int argc, char **argv) { swaynag_types_free(types); + struct swaynag_button button_close = { 0 }; + button_close.text = strdup("X"); + button_close.type = SWAYNAG_ACTION_DISMISS; + list_add(swaynag.buttons, &button_close); + if (swaynag.details.message) { list_add(swaynag.buttons, &swaynag.details.button_details); } |
