GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Functions
gp_block_alloc.h File Reference

Simple block allocator. More...

#include <stddef.h>
#include <core/gp_compiler.h>

Go to the source code of this file.

Functions

void * gp_balloc (gp_balloc_pool **self, size_t size)
 Allocate memory from a block pool.
 
void gp_bfree (gp_balloc_pool **self)
 Free all blocks in the allocator.
 

Detailed Description

Simple block allocator.

This is simple allocator for cases where we want to free all memory at once.

The allocator allocates memory in size pre-defined blocks and hands out memory from such pools until the block memory is exhausted. The allocator does not have to maintain free blocks, since all memory is freed at once, which makes the code super simple and fast.

Definition in file gp_block_alloc.h.

Function Documentation

◆ gp_balloc()

void * gp_balloc ( gp_balloc_pool **  self,
size_t  size 
)

Allocate memory from a block pool.

The pointer to the gp_balloc has to be set to NULL prior first call to this function.

Parameters
selfA pointer to a block pointer.
sizeA memory size to be allocated.
Returns
A pointer to allocated memory, returns NULL on a failure.

◆ gp_bfree()

void gp_bfree ( gp_balloc_pool **  self)

Free all blocks in the allocator.

Parameters
selfA pointer to a block pointer.