From: Pawel Wodkowski Date: Wed, 25 Feb 2015 12:41:24 +0000 (+0100) Subject: kvargs: fix freeing behaviour for null X-Git-Tag: spdx-start~9500 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c34af7424e09;p=dpdk.git kvargs: fix freeing behaviour for null By convention free() functions should ignore NULL parameter. This patch add this behaviour for rte_kvargs_free(). Signed-off-by: Pawel Wodkowski Acked-by: Olivier Matz --- diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 8bc1e46117..c2dd051336 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 ef4efabfb5..ae9ae79f21 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