In a buddy system algorithm, the heap manager allocates only a specific chunk of memory to be a permitted size. For each permitted size, there is an idle list to maintain.
Generally these sizes will choose the power of 2, or Fibonacci sequence. This makes it easy to divide the number of other numbers except the smallest to two permitted size.
When the heap manager that is responsible for allocating memory receives a memory request of the size of S, it speaks of S-aligned to a permitted size. Then allocate a chunk of memory from that permitted size's free list to him. If the memory is not found in that free list, a memory is allocated to the user at a large level of memory, and the remaining half is then suspended to the permitted size's free list.
The free list in this algorithm is usually implemented by bitmap (bitmap) algorithm. This can make memory collection merging very efficient.
In the Zend engine of the heap management algorithm used in the partner system algorithm, we look at the ZEND_MM_HEAP structure of the relevant data structures:
Zend_mm_free_block *free_buckets[zend_mm_num_buckets*2];
This free_buckets is a two-bit array of free linked lists. Zend_mm_num_buckets defines the maximum power value at the time of allocation. Each power value corresponds to a *free_buckets, which is an idle list.