rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
{
unsigned i;
- char *str, *ctx1, *ctx2;
+ char *str;
+ char *ctx1 = NULL;
+ char *ctx2 = NULL;
/* Copy the const char *params to a modifiable string
* to pass to rte_strsplit
ret = 0;
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
- if (strcmp(pair->key, key_match) == 0)
+ if (key_match == NULL || strcmp(pair->key, key_match) == 0)
ret++;
}
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
- if (strcmp(pair->key, key_match) == 0) {
+ if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
return -1;
}
void
rte_kvargs_free(struct rte_kvargs *kvlist)
{
+ if (!kvlist)
+ return;
+
if (kvlist->str != NULL)
free(kvlist->str);
+
free(kvlist);
}