[ZBX-15062] Binary heap always attempts to reallocate buffer when element is added Created: 2018 Oct 24  Updated: 2024 Apr 10  Resolved: 2018 Nov 06

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 3.0.22, 3.4.14, 4.0.1rc1, 4.2.0alpha1
Fix Version/s: 3.0.24rc1, 4.0.2rc1, 4.2.0alpha1, 4.2 (plan)

Type: Problem report Priority: Minor
Reporter: Andris Zeila Assignee: Andris Zeila
Resolution: Fixed Votes: 0
Labels: cache, performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team A
Sprint: Sprint 46, Nov 2018
Story Points: 0.125

 Description   

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));


 Comments   
Comment by Andris Zeila [ 2018 Nov 06 ]

Released in:

  • pre-3.0.24rc1 r86497
  • pre-4.0.2rc1 r86498
  • pre-4.2.0alpha1 r86499
Generated at Sat Apr 27 07:40:27 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.