From 12cb866389361e766488700cb77c3936174ecac1 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 9 Jan 2014 13:51:57 +0000 Subject: [PATCH] Simplify args_set, from Tiago Cunha. --- usr.bin/tmux/arguments.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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. */ -- 2.20.1