X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fprio_heap%2Fprio_heap.c;fp=lib%2Fprio_heap%2Fprio_heap.c;h=092f0095f874844d58ba5460b16b31eadfddd3ff;hp=a37e64c89542d10f017f8da835e01272dab2e2ef;hb=23a151f0f9301b6fee28c9b0e8301f1f50e4ef9b;hpb=ff075710d7cc7ab92dc1cd20b048a28af42b2fa8 diff --git a/lib/prio_heap/prio_heap.c b/lib/prio_heap/prio_heap.c index a37e64c8..092f0095 100644 --- a/lib/prio_heap/prio_heap.c +++ b/lib/prio_heap/prio_heap.c @@ -214,3 +214,21 @@ found: heapify(heap, pos); return p; } + +int heap_copy(struct ptr_heap *dst, struct ptr_heap *src) +{ + int ret; + + ret = heap_init(dst, src->alloc_len, src->gt); + if (ret < 0) + goto end; + + ret = heap_set_len(dst, src->len); + if (ret < 0) + goto end; + + memcpy(dst->ptrs, src->ptrs, src->len * sizeof(void *)); + +end: + return ret; +}