projects
/
project
/
procd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add askfirst tool
[project/procd.git]
/
utils.c
diff --git
a/utils.c
b/utils.c
index
88ed8c1
..
628136f
100644
(file)
--- a/
utils.c
+++ b/
utils.c
@@
-3,15
+3,16
@@
#include "utils.h"
void
#include "utils.h"
void
-__blobmsg_list_init(struct blobmsg_list *list, int offset, int len)
+__blobmsg_list_init(struct blobmsg_list *list, int offset, int len
, blobmsg_list_cmp cmp
)
{
avl_init(&list->avl, avl_strcmp, false, NULL);
list->node_offset = offset;
list->node_len = len;
{
avl_init(&list->avl, avl_strcmp, false, NULL);
list->node_offset = offset;
list->node_len = len;
+ list->cmp = cmp;
}
int
}
int
-blobmsg_list_fill(struct blobmsg_list *list, void *data, int len)
+blobmsg_list_fill(struct blobmsg_list *list, void *data, int len
, bool array
)
{
struct avl_tree *tree = &list->avl;
struct blobmsg_list_node *node;
{
struct avl_tree *tree = &list->avl;
struct blobmsg_list_node *node;
@@
-21,7
+22,7
@@
blobmsg_list_fill(struct blobmsg_list *list, void *data, int len)
int rem = len;
__blob_for_each_attr(cur, data, rem) {
int rem = len;
__blob_for_each_attr(cur, data, rem) {
- if (!blobmsg_check_attr(cur,
true
))
+ if (!blobmsg_check_attr(cur,
!array
))
continue;
ptr = calloc(1, list->node_len);
continue;
ptr = calloc(1, list->node_len);
@@
-29,7
+30,10
@@
blobmsg_list_fill(struct blobmsg_list *list, void *data, int len)
return -1;
node = (void *) ((char *)ptr + list->node_offset);
return -1;
node = (void *) ((char *)ptr + list->node_offset);
- node->avl.key = blobmsg_name(cur);
+ if (array)
+ node->avl.key = blobmsg_data(cur);
+ else
+ node->avl.key = blobmsg_name(cur);
node->data = cur;
if (avl_insert(tree, &node->avl)) {
free(ptr);
node->data = cur;
if (avl_insert(tree, &node->avl)) {
free(ptr);
@@
-49,7
+53,7
@@
blobmsg_list_move(struct blobmsg_list *list, struct blobmsg_list *src)
void *ptr;
avl_remove_all_elements(&src->avl, node, avl, tmp) {
void *ptr;
avl_remove_all_elements(&src->avl, node, avl, tmp) {
- if (
!
avl_insert(&list->avl, &node->avl)) {
+ if (avl_insert(&list->avl, &node->avl)) {
ptr = ((char *) node - list->node_offset);
free(ptr);
}
ptr = ((char *) node - list->node_offset);
free(ptr);
}
@@
-90,6
+94,9
@@
blobmsg_list_equal(struct blobmsg_list *l1, struct blobmsg_list *l2)
if (memcmp(n1->data, n2->data, len) != 0)
return false;
if (memcmp(n1->data, n2->data, len) != 0)
return false;
+ if (l1->cmp && !l1->cmp(n1, n2))
+ return false;
+
if (!count)
break;
if (!count)
break;