X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fprio_heap%2Fprio_heap.c;h=8942a113aec50038fe20f59c6bbf84756a2d780d;hp=092f0095f874844d58ba5460b16b31eadfddd3ff;hb=bb35f032b52330cfb17c144bfed81f2b1569f308;hpb=23a151f0f9301b6fee28c9b0e8301f1f50e4ef9b diff --git a/lib/prio_heap/prio_heap.c b/lib/prio_heap/prio_heap.c index 092f0095..8942a113 100644 --- a/lib/prio_heap/prio_heap.c +++ b/lib/prio_heap/prio_heap.c @@ -15,6 +15,14 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ #include @@ -94,7 +102,7 @@ int heap_set_len(struct ptr_heap *heap, size_t new_len) return 0; } -int heap_init(struct ptr_heap *heap, size_t alloc_len, +int bt_heap_init(struct ptr_heap *heap, size_t alloc_len, int gt(void *a, void *b)) { heap->ptrs = NULL; @@ -103,12 +111,12 @@ int heap_init(struct ptr_heap *heap, size_t alloc_len, heap->gt = gt; /* * Minimum size allocated is 1 entry to ensure memory allocation - * never fails within heap_replace_max. + * never fails within bt_heap_replace_max. */ return heap_grow(heap, max_t(size_t, 1, alloc_len)); } -void heap_free(struct ptr_heap *heap) +void bt_heap_free(struct ptr_heap *heap) { free(heap->ptrs); } @@ -139,7 +147,7 @@ static void heapify(struct ptr_heap *heap, size_t i) check_heap(heap); } -void *heap_replace_max(struct ptr_heap *heap, void *p) +void *bt_heap_replace_max(struct ptr_heap *heap, void *p) { void *res; @@ -157,7 +165,7 @@ void *heap_replace_max(struct ptr_heap *heap, void *p) return res; } -int heap_insert(struct ptr_heap *heap, void *p) +int bt_heap_insert(struct ptr_heap *heap, void *p) { void **ptrs; size_t pos; @@ -178,7 +186,7 @@ int heap_insert(struct ptr_heap *heap, void *p) return 0; } -void *heap_remove(struct ptr_heap *heap) +void *bt_heap_remove(struct ptr_heap *heap) { switch (heap->len) { case 0: @@ -190,10 +198,10 @@ void *heap_remove(struct ptr_heap *heap) /* Shrink, replace the current max by previous last entry and heapify */ heap_set_len(heap, heap->len - 1); /* len changed. previous last entry is at heap->len */ - return heap_replace_max(heap, heap->ptrs[heap->len]); + return bt_heap_replace_max(heap, heap->ptrs[heap->len]); } -void *heap_cherrypick(struct ptr_heap *heap, void *p) +void *bt_heap_cherrypick(struct ptr_heap *heap, void *p) { size_t pos, len = heap->len; @@ -215,11 +223,11 @@ found: return p; } -int heap_copy(struct ptr_heap *dst, struct ptr_heap *src) +int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src) { int ret; - ret = heap_init(dst, src->alloc_len, src->gt); + ret = bt_heap_init(dst, src->alloc_len, src->gt); if (ret < 0) goto end;