summaryrefslogtreecommitdiff
path: root/lib/librte_kvargs
diff options
context:
space:
mode:
authorPawel Wodkowski <pawelx.wodkowski@intel.com>2015-02-25 13:41:24 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-03-04 11:19:37 +0100
commitc34af7424e092bd5e12ae84993a6ba64fe64d18f (patch)
tree3c9be6174bc5c3195fe163c46223d4fc33d72f85 /lib/librte_kvargs
parent5663c25dcceb744b980ff28df5687de7ec8cbbf8 (diff)
downloaddpdk-c34af7424e092bd5e12ae84993a6ba64fe64d18f.zip
dpdk-c34af7424e092bd5e12ae84993a6ba64fe64d18f.tar.gz
dpdk-c34af7424e092bd5e12ae84993a6ba64fe64d18f.tar.xz
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 <pawelx.wodkowski@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib/librte_kvargs')
-rw-r--r--lib/librte_kvargs/rte_kvargs.c4
-rw-r--r--lib/librte_kvargs/rte_kvargs.h3
2 files changed, 6 insertions, 1 deletions
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