RTEMS 6.1-rc6
|
Description for free or used blocks. More...
#include <heap.h>
Data Fields | |
uintptr_t | prev_size |
Size of the previous block or part of the allocated area of the previous block. | |
uintptr_t | size_and_flag |
Contains the size of the current block and a flag which indicates if the previous block is free or used. | |
Heap_Block * | next |
Pointer to the next free block or part of the allocated area. | |
Heap_Block * | prev |
Pointer to the previous free block or part of the allocated area. | |
Description for free or used blocks.
Heap_Block* Heap_Block::next |
Pointer to the next free block or part of the allocated area.
This field is page size aligned and begins of the allocated area in case the block is used.
This field is only valid if the block is free and thus part of the free block list.
Heap_Block* Heap_Block::prev |
Pointer to the previous free block or part of the allocated area.
This field is only valid if the block is free and thus part of the free block list.
uintptr_t Heap_Block::prev_size |
Size of the previous block or part of the allocated area of the previous block.
This field is only valid if the previous block is free. This case is indicated by a cleared HEAP_PREV_BLOCK_USED
flag in the size_and_flag field of the current block.
In a used block only the size_and_flag field needs to be valid. The prev_size field of the current block is maintained by the previous block. The current block can use the prev_size field in the next block for allocation.
uintptr_t Heap_Block::size_and_flag |
Contains the size of the current block and a flag which indicates if the previous block is free or used.
If the flag HEAP_PREV_BLOCK_USED
is set, then the previous block is used, otherwise the previous block is free. A used previous block may claim the prev_size field for allocation. This trick allows to decrease the overhead in the used blocks by the size of the prev_size field. As sizes are required to be multiples of two, the least significant bits would be always zero. We use this bit to store the flag.
This field is always valid.