Skip to content

Commit

Permalink
Simplify args_set, from Tiago Cunha.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Jan 9, 2014
1 parent 1751da7 commit 66829ee
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,15 @@ args_set(struct args *args, u_char ch, const char *value)
/* Replace existing argument. */
if ((entry = args_find(args, ch)) != NULL) {
free(entry->value);
if (value != NULL)
entry->value = xstrdup(value);
else
entry->value = NULL;
return;
entry->value = NULL;
} else {
entry = xcalloc(1, sizeof *entry);
entry->flag = ch;
RB_INSERT(args_tree, &args->tree, entry);
}

entry = xcalloc(1, sizeof *entry);
entry->flag = ch;
if (value != NULL)
entry->value = xstrdup(value);

RB_INSERT(args_tree, &args->tree, entry);
}

/* Get argument value. Will be NULL if it isn't present. */
Expand Down

0 comments on commit 66829ee

Please sign in to comment.