From: nicm Date: Thu, 9 Jan 2014 13:51:57 +0000 (+0000) Subject: Simplify args_set, from Tiago Cunha. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=12cb866389361e766488700cb77c3936174ecac1;p=openbsd Simplify args_set, from Tiago Cunha. --- diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c index 37c23dee824..46c012f3450 100644 --- a/usr.bin/tmux/arguments.c +++ b/usr.bin/tmux/arguments.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arguments.c,v 1.6 2013/11/17 20:19:36 okan Exp $ */ +/* $OpenBSD: arguments.c,v 1.7 2014/01/09 13:51:57 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott @@ -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. */