From 4ee5488830d35bdb67b71ba56c3663d40703b80d Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Tue, 19 Nov 2024 11:19:28 +0000 Subject: [PATCH] infostore: general tidyup Tidy up some of the code; no functional changes. --- fvwm/infostore.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/fvwm/infostore.c b/fvwm/infostore.c index 08ed372a6..6da778604 100644 --- a/fvwm/infostore.c +++ b/fvwm/infostore.c @@ -83,16 +83,12 @@ void insert_metainfo(char *key, char *value) static void delete_metainfo(const char *key) { - MetaInfo *mi = NULL; + MetaInfo *mi = NULL, *mi1; - TAILQ_FOREACH(mi, &meta_info_q, entry) - { - if (StrEquals(mi->key, key)) - break; - } - - if (mi != NULL) + TAILQ_FOREACH_SAFE(mi, &meta_info_q, entry, mi1) { + if (!StrEquals(mi->key, key)) + continue; TAILQ_REMOVE(&meta_info_q, mi, entry); free(mi->key); @@ -138,28 +134,14 @@ void print_infostore(void) /* ---------------------------- builtin commands --------------------------- */ void CMD_InfoStoreAdd(F_CMD_ARGS) { - char *key, *value; + char *key = NULL, *value = NULL; char *token; token = PeekToken(action, &action); - key = value = NULL; - - if (token) - key = strdup(token); + key = fxstrdup(token); token = PeekToken(action, &action); - - if (token) - value = strdup(token); - - if (!key || !value) - { - fvwm_debug(__func__, "Bad arguments given."); - if (key) - free(key); - - return; - } + value = fxstrdup(token); insert_metainfo(key, value); free(key);