Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infostore: general tidyup #1114

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading