X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fprio_heap%2Fprio_heap.c;h=092f0095f874844d58ba5460b16b31eadfddd3ff;hp=a37e64c89542d10f017f8da835e01272dab2e2ef;hb=9b3c1d6f8e01603488e317ffef7a8e3c15c98459;hpb=74f21e2d288b83a1e810a20eaa6503bb25b7059f 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; +}