From 063b8c2b5301646335dac66f1167bc8f128537a7 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 24 Jun 2012 18:38:54 +0200 Subject: [PATCH] add blobmsg_list_move --- utils.c | 14 ++++++++++++++ utils.h | 1 + 2 files changed, 15 insertions(+) diff --git a/utils.c b/utils.c index cf31f87..88ed8c1 100644 --- a/utils.c +++ b/utils.c @@ -42,6 +42,20 @@ blobmsg_list_fill(struct blobmsg_list *list, void *data, int len) return count; } +void +blobmsg_list_move(struct blobmsg_list *list, struct blobmsg_list *src) +{ + struct blobmsg_list_node *node, *tmp; + void *ptr; + + avl_remove_all_elements(&src->avl, node, avl, tmp) { + if (!avl_insert(&list->avl, &node->avl)) { + ptr = ((char *) node - list->node_offset); + free(ptr); + } + } +} + void blobmsg_list_free(struct blobmsg_list *list) { diff --git a/utils.h b/utils.h index 77de1f0..e89f2f1 100644 --- a/utils.h +++ b/utils.h @@ -26,5 +26,6 @@ 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); +void blobmsg_list_move(struct blobmsg_list *list, struct blobmsg_list *src); #endif -- 2.25.1