projects
/
project
/
libubox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jshn: fix format string for int64 type
[project/libubox.git]
/
kvlist.c
diff --git
a/kvlist.c
b/kvlist.c
index
e0a8acb
..
a7b6ea0
100644
(file)
--- a/
kvlist.c
+++ b/
kvlist.c
@@
-71,20
+71,25
@@
bool kvlist_delete(struct kvlist *kv, const char *name)
return !!node;
}
return !!node;
}
-
void
kvlist_set(struct kvlist *kv, const char *name, const void *data)
+
bool
kvlist_set(struct kvlist *kv, const char *name, const void *data)
{
struct kvlist_node *node;
char *name_buf;
int len = kv->get_len(kv, data);
{
struct kvlist_node *node;
char *name_buf;
int len = kv->get_len(kv, data);
- kvlist_delete(kv, name);
-
node = calloc_a(sizeof(struct kvlist_node) + len,
&name_buf, strlen(name) + 1);
node = calloc_a(sizeof(struct kvlist_node) + len,
&name_buf, strlen(name) + 1);
+ if (!node)
+ return false;
+
+ kvlist_delete(kv, name);
+
memcpy(node->data, data, len);
node->avl.key = strcpy(name_buf, name);
avl_insert(&kv->avl, &node->avl);
memcpy(node->data, data, len);
node->avl.key = strcpy(name_buf, name);
avl_insert(&kv->avl, &node->avl);
+
+ return true;
}
void kvlist_free(struct kvlist *kv)
}
void kvlist_free(struct kvlist *kv)