diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-06-10 17:31:54 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-06-10 17:31:54 +0200 |
commit | c596f040369f0900e2818e249c00c44c33b6eb64 (patch) | |
tree | 9d530780eeecdc4d74c21105c9d2a48585d8fe82 | |
parent | 542b153eedebecb8ae0aae22596608f150ad6be3 (diff) | |
download | unitd-c596f040369f0900e2818e249c00c44c33b6eb64.tar unitd-c596f040369f0900e2818e249c00c44c33b6eb64.zip |
add blobmsg_list_equal()
-rw-r--r-- | utils.c | 32 | ||||
-rw-r--r-- | utils.h | 1 |
2 files changed, 33 insertions, 0 deletions
@@ -53,3 +53,35 @@ blobmsg_list_free(struct blobmsg_list *list) free(ptr); } } + +bool +blobmsg_list_equal(struct blobmsg_list *l1, struct blobmsg_list *l2) +{ + struct blobmsg_list_node *n1, *n2; + int count = l1->avl.count; + + if (count != l2->avl.count) + return false; + + n1 = avl_first_element(&l1->avl, n1, avl); + n2 = avl_first_element(&l2->avl, n2, avl); + + while (count-- > 0) { + int len; + + len = blob_len(n1->data); + if (len != blob_len(n2->data)) + return false; + + if (memcmp(n1->data, n2->data, len) != 0) + return false; + + if (!count) + break; + + n1 = avl_next_element(n1, avl); + n2 = avl_next_element(n2, avl); + } + + return true; +} @@ -25,5 +25,6 @@ struct blobmsg_list_node { void __blobmsg_list_init(struct blobmsg_list *list, int offset, int len); int blobmsg_list_fill(struct blobmsg_list *list, void *data, int len); void blobmsg_list_free(struct blobmsg_list *list); +bool blobmsg_list_equal(struct blobmsg_list *l1, struct blobmsg_list *l2); #endif |