From 9099adbbe6fffcd7510b31efc8e547da7fa24f65 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Fri, 19 Apr 2019 22:44:11 -0400 Subject: swaynag: revamp type configs This revamps the type configs for swaynag. All sizing attributes for swaynag are now `ssize_t` instead of `uint32_t` to allow for a default value of `-1`, which allows for `0` to be a valid value. Additionally, the initialization of the type configs has been changed from a simple calloc to use a new function `swaynag_type_new`. `swaynag_type_new` calloc's the memory, checks for an allocation failure, sets the name, and all sizes to -1. The layering order has also been changed to default, general config, type config, and as highest priority command line arguments. Finally, `swaynag_type_merge` has been modified to handle the layering and sizing changes. --- swaynag/config.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'swaynag/config.c') diff --git a/swaynag/config.c b/swaynag/config.c index fb2aa820..2fa7cb61 100644 --- a/swaynag/config.c +++ b/swaynag/config.c @@ -332,9 +332,7 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) { return 0; } - struct swaynag_type *type; - type = calloc(1, sizeof(struct swaynag_type)); - type->name = strdup(""); + struct swaynag_type *type = swaynag_type_new(""); list_add(types, type); char *line = NULL; @@ -364,8 +362,7 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) { strncat(name, line + 1, close - line - 1); type = swaynag_type_get(types, name); if (!type) { - type = calloc(1, sizeof(struct swaynag_type)); - type->name = strdup(name); + type = swaynag_type_new(name); list_add(types, type); } free(name); -- cgit v1.2.3