Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-15062

Binary heap always attempts to reallocate buffer when element is added

    XMLWordPrintable

Details

    • Team A
    • Sprint 46, Nov 2018
    • 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));
      

      Attachments

        Activity

          People

            wiper Andris Zeila
            wiper Andris Zeila
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: