Blender  V3.3
Classes | Macros | Functions
BLI_memblock.c File Reference
#include <stdlib.h>
#include <string.h>
#include "atomic_ops.h"
#include "BLI_utildefines.h"
#include "BLI_memblock.h"
#include "MEM_guardedalloc.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  BLI_memblock
 

Macros

#define CHUNK_LIST_SIZE   16
 

Functions

BLI_memblockBLI_memblock_create_ex (uint elem_size, uint chunk_size)
 
void BLI_memblock_destroy (BLI_memblock *mblk, MemblockValFreeFP free_callback)
 
void BLI_memblock_clear (BLI_memblock *mblk, MemblockValFreeFP free_callback)
 
voidBLI_memblock_alloc (BLI_memblock *mblk)
 
void BLI_memblock_iternew (BLI_memblock *mblk, BLI_memblock_iter *iter)
 
voidBLI_memblock_iterstep (BLI_memblock_iter *iter)
 
voidBLI_memblock_elem_get (BLI_memblock *mblk, int chunk, int elem)
 

Detailed Description

Dead simple, fast memory allocator for allocating many elements of the same size.

Definition in file BLI_memblock.c.

Macro Definition Documentation

◆ CHUNK_LIST_SIZE

#define CHUNK_LIST_SIZE   16

Definition at line 24 of file BLI_memblock.c.

Function Documentation

◆ BLI_memblock_alloc()

void* BLI_memblock_alloc ( BLI_memblock mblk)

◆ BLI_memblock_clear()

void BLI_memblock_clear ( BLI_memblock mblk,
MemblockValFreeFP  free_callback 
)

◆ BLI_memblock_create_ex()

BLI_memblock* BLI_memblock_create_ex ( uint  elem_size,
uint  chunk_size 
)

◆ BLI_memblock_destroy()

void BLI_memblock_destroy ( BLI_memblock mblk,
MemblockValFreeFP  free_callback 
)

◆ BLI_memblock_elem_get()

void* BLI_memblock_elem_get ( BLI_memblock mblk,
int  chunk,
int  elem 
)

Direct access. elem is element index inside the chosen chunk. Double usage: You can set chunk to 0 and set the absolute elem index. The correct chunk will be retrieve.

Definition at line 176 of file BLI_memblock.c.

References BLI_assert, BLI_memblock::chunk_list, BLI_memblock::chunk_size, and BLI_memblock::elem_size.

Referenced by DRW_memblock_elem_from_handle(), drw_resource_buffer_finish(), and workbench_material_chunk_select().

◆ BLI_memblock_iternew()

void BLI_memblock_iternew ( BLI_memblock mblk,
BLI_memblock_iter iter 
)

◆ BLI_memblock_iterstep()

void* BLI_memblock_iterstep ( BLI_memblock_iter iter)