-
Problem report
-
Resolution: Fixed
-
Minor
-
3.0.22, 3.4.14, 4.0.1rc1, 4.2.0alpha1
-
Sprint 46, Nov 2018
-
0.125
When inserting an element binary heap will always attempt to reallocate buffer. If the buffer does not have to be expanded it will be reallocated with the current size. It's not a critical problem (memory allocator will check that the current size is enough and ignore request), but still needs to be fixed:
Index: src/libs/zbxalgo/binaryheap.c =================================================================== --- src/libs/zbxalgo/binaryheap.c (revision 85993) +++ src/libs/zbxalgo/binaryheap.c (working copy) @@ -68,7 +68,7 @@ else if (heap->elems_num == heap->elems_alloc) tmp_elems_alloc = MAX(heap->elems_alloc + 1, heap->elems_alloc * ARRAY_GROWTH_FACTOR); - if (heap->elems_num != tmp_elems_alloc) + if (heap->elems_alloc != tmp_elems_alloc) { heap->elems = heap->mem_realloc_func(heap->elems, tmp_elems_alloc * sizeof(zbx_binary_heap_elem_t));