MiniGUI API Reference (MiniGUI-Standalone)  v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Data Structures | Typedefs | Functions
Block data heap operations

Data Structures

struct  _BLOCKHEAP


 Data type of the pointer to a BLOCKHEAP. More...


MG_EXPORT void InitBlockDataHeap (PBLOCKHEAP heap, size_t bd_size, size_t heap_size)
 Initializes a private block data heap. More...
MG_EXPORT void * BlockDataAlloc (PBLOCKHEAP heap)
 Allocates a data block from private heap. More...
MG_EXPORT void BlockDataFree (PBLOCKHEAP heap, void *data)
 Frees an allocated data block. More...
MG_EXPORT void DestroyBlockDataHeap (PBLOCKHEAP heap)
 Destroys a private block data heap. More...

Detailed Description

MiniGUI maintains some private block data heaps to allocate data blocks which have fixed size, such as the clipping rectangles in a region. By using the private heap, we can avoiding calling malloc and free function frequently, so will have a slight performance enhancement.

Typedef Documentation


MiniGUI's private block data heap.

See also
InitBlockDataHeap, DestroyBlockDataHeap

Data type of the pointer to a BLOCKHEAP.

See also

Definition at line 421 of file gdi.h.

Function Documentation

void * BlockDataAlloc ( PBLOCKHEAP  heap)

Allocates a data block from private heap.

This function allocates a data block from an initialized block data heap. The allocated block will have the size of heap->bd_size. If there is no free block in the heap, this function will try to allocate the block from the system heap by using malloc(3) function.

heapThe pointer to the initialized heap.
Pointer to the allocated data block, NULL on error.
See also
InitBlockDataHeap, BlockDataFree
void BlockDataFree ( PBLOCKHEAP  heap,
void *  data 

Frees an allocated data block.

This function frees the specified data block pointed to by data to the heap heap. If the block was allocated by using malloc function, this function will free the element by using free(3) function.

heapThe pointer to the heap.
dataThe pointer to the element to be freed.
See also
InitBlockDataHeap, BlockDataAlloc
void DestroyBlockDataHeap ( PBLOCKHEAP  heap)

Destroys a private block data heap.

heapThe pointer to the heap to be destroied.
See also
InitBlockDataHeap, BLOCKHEAP
void InitBlockDataHeap ( PBLOCKHEAP  heap,
size_t  bd_size,
size_t  heap_size 

Initializes a private block data heap.

This function initializes a block data heap pointed to by heap. It will allocate the buffer used by the heap from system heap by using malloc(3). Initially, the heap has heap_size blocks free, and each is bd_size bytes long.

heapThe pointer to the heap structure.
bd_sizeThe size of one block in bytes.
heap_sizeThe size of the heap in blocks.
heap->heap will contains a valid pointer on success, NULL on error.
This function does not return anything. You should check the heap field of the heap structure.
See also