From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 5B4329A99 for ; Wed, 25 Feb 2015 13:53:42 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 25 Feb 2015 04:53:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,644,1418112000"; d="scan'208";a="656979057" Received: from unknown (HELO Sent) ([10.217.248.233]) by orsmga001.jf.intel.com with SMTP; 25 Feb 2015 04:53:39 -0800 Received: by Sent (sSMTP sendmail emulation); Wed, 25 Feb 2015 13:46:06 +0100 From: Pawel Wodkowski To: dev@dpdk.org Date: Wed, 25 Feb 2015 13:41:24 +0100 Message-Id: <1424868086-4232-3-git-send-email-pawelx.wodkowski@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424868086-4232-1-git-send-email-pawelx.wodkowski@intel.com> References: <1424700600-1765-1-git-send-email-pawelx.wodkowski@intel.com> <1424868086-4232-1-git-send-email-pawelx.wodkowski@intel.com> Subject: [dpdk-dev] [PATCH v2 2/4] librte_kvargs: make rte_kvargs_free() be consistent with other "free()" functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2015 12:53:42 -0000 By convenction free() functions should ignore NULL parameter. This patch add this behaviour for rte_kvargs_free(). Signed-off-by: Pawel Wodkowski --- lib/librte_kvargs/rte_kvargs.c | 4 ++++ lib/librte_kvargs/rte_kvargs.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 8bc1e46..c2dd051 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -174,8 +174,12 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, void rte_kvargs_free(struct rte_kvargs *kvlist) { + if (!kvlist) + return; + if (kvlist->str != NULL) free(kvlist->str); + free(kvlist); } diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h index ef4efab..ae9ae79 100644 --- a/lib/librte_kvargs/rte_kvargs.h +++ b/lib/librte_kvargs/rte_kvargs.h @@ -115,7 +115,8 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); * * For each key/value association that matches the given key, calls the * handler function with the for a given arg_name passing the value on the - * dictionary for that key and a given extra argument. + * dictionary for that key and a given extra argument. If *kvlist* is NULL + * function does nothing. * * @param kvlist * The rte_kvargs structure -- 1.9.1