GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Macros
gp_temp_alloc.h File Reference

Temporary block allocator implementation. More...

#include <stdlib.h>
#include <core/gp_common.h>

Go to the source code of this file.

Data Structures

struct  gp_temp_alloc
 Temporary buffer. More...
 

Macros

#define gp_temp_alloc_free(self)
 Frees a temporary allocated memory.
 

Detailed Description

Temporary block allocator implementation.

Creates pool for block allocation (small ones are done on the stack, bigger using malloc).

The usage is:

// Creates new allocation pool
gp_temp_alloc_create(buf, 3 * 1024);
// Make use of it
int *R = gp_temp_alloc_get(buf, 1024);
int *G = gp_temp_alloc_get(buf, 1024);
int *B = gp_temp_alloc_get(buf, 1024);
...
// Free it
gp_temp_alloc_free(buf);

Definition in file gp_temp_alloc.h.

Macro Definition Documentation

◆ gp_temp_alloc_free

#define gp_temp_alloc_free (   self)
Value:
do { \
if (self.size > GP_ALLOCA_THRESHOLD) \
free(self.buffer); \
} while (0)

Frees a temporary allocated memory.

Parameters
selfA temporary allocator.

Definition at line 79 of file gp_temp_alloc.h.