RTEMS  5.0.0
Data Fields
Heap_Block Struct Reference

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. More...
 
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. More...
 
Heap_Blocknext
 Pointer to the next free block or part of the allocated area. More...
 
Heap_Blockprev
 Pointer to the previous free block or part of the allocated area. More...
 

Detailed Description

Description for free or used blocks.

Field Documentation

◆ next

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.

◆ prev

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.

◆ prev_size

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.

◆ size_and_flag

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.


The documentation for this struct was generated from the following file: