Skip to content

Commit

Permalink
infostore: general tidyup
Browse files Browse the repository at this point in the history
Tidy up some of the code; no functional changes.
  • Loading branch information
ThomasAdam committed Nov 19, 2024
1 parent c27e389 commit 69d4903
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions fvwm/infostore.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,20 @@ 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)
TAILQ_FOREACH_SAFE(mi, &meta_info_q, entry, mi1)
{
if (StrEquals(mi->key, key))
break;
}
if (StrEquals(mi->key, key)) {
TAILQ_REMOVE(&meta_info_q, mi, entry);

if (mi != NULL)
{
TAILQ_REMOVE(&meta_info_q, mi, entry);
free(mi->key);
free(mi->value);
free(mi);

free(mi->key);
free(mi->value);
free(mi);
return;
}
}

return;
}

inline char *get_metainfo_value(const char *key)
Expand Down Expand Up @@ -138,30 +134,24 @@ 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);

token = PeekToken(action, &action);
if ((token = PeekToken(action, &action)) == NULL)
goto error;
key = fxstrdup(token);

if (token)
value = strdup(token);
if ((token = PeekToken(action, &action)) == NULL)
goto error;
value = fxstrdup(token);

if (!key || !value)
{
error:
if (key == NULL || value == NULL) {
fvwm_debug(__func__, "Bad arguments given.");
if (key)
free(key);

return;
goto out;
}

insert_metainfo(key, value);
out:
free(key);
free(value);

Expand All @@ -174,7 +164,7 @@ void CMD_InfoStoreRemove(F_CMD_ARGS)

token = PeekToken(action, &action);

if (!token)
if (token == NULL)
{
fvwm_debug(__func__, "No key given to remove item.");
return;
Expand Down

0 comments on commit 69d4903

Please sign in to comment.