[dpdk-dev] [PATCH 05/11] kvargs: rework API to fix memory leak
bruce.richardson at intel.com
Thu Jan 30 12:22:42 CET 2014
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Olivier Matz
> Sent: Tuesday, January 28, 2014 4:07 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH 05/11] kvargs: rework API to fix memory leak
> Before the patch, a call to rte_kvargs_tokenize() resulted in a call to
> strdup() to allocate a modifiable copy of the argument string. This string
> was never freed, excepted in the error cases of
> rte_kvargs_tokenize() where rte_free() was wrongly called instead of free().
> In other cases, freeing this string was impossible as the pointer not saved.
> This patch introduces rte_kvargs_free() in order to free the structure
> properly. The pointer to the duplicated string is now kept in the rte_kvargs
> structure. A call to rte_kvargs_parse() directly allocates the structure,
> making rte_kvargs_init() useless.
> The only drawback of this API change is that a key/value associations
> cannot be added to an existing kvlist. But it's not used today, and there is
> not obvious use case for that.
> Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
> lib/librte_kvargs/Makefile | 3 +-
> lib/librte_kvargs/rte_kvargs.c | 64 ++++++++++++++++++--------------------
> lib/librte_kvargs/rte_kvargs.h | 42 +++++++++++--------------
> lib/librte_pmd_pcap/rte_eth_pcap.c | 27 ++++++++--------
> 4 files changed, 63 insertions(+), 73 deletions(-)
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
More information about the dev