Blender  V2.93
Classes | Typedefs | Enumerations | Functions
BLI_mempool.h File Reference
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Classes

struct  BLI_mempool_iter
 

Typedefs

typedef struct BLI_mempool BLI_mempool
 
typedef struct BLI_mempool_iter BLI_mempool_iter
 

Enumerations

enum  { BLI_MEMPOOL_NOP = 0 , BLI_MEMPOOL_ALLOW_ITER = (1 << 0) }
 

Functions

BLI_mempoolBLI_mempool_create (unsigned int esize, unsigned int totelem, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
 
void * BLI_mempool_alloc (BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 
void * BLI_mempool_calloc (BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 
void BLI_mempool_free (BLI_mempool *pool, void *addr) ATTR_NONNULL(1
 
void void BLI_mempool_clear_ex (BLI_mempool *pool, const int totelem_reserve) ATTR_NONNULL(1)
 
void BLI_mempool_clear (BLI_mempool *pool) ATTR_NONNULL(1)
 
void BLI_mempool_destroy (BLI_mempool *pool) ATTR_NONNULL(1)
 
int BLI_mempool_len (BLI_mempool *pool) ATTR_NONNULL(1)
 
void * BLI_mempool_findelem (BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 
void BLI_mempool_as_table (BLI_mempool *pool, void **data) ATTR_NONNULL(1
 
void void ** BLI_mempool_as_tableN (BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
void void void BLI_mempool_as_array (BLI_mempool *pool, void *data) ATTR_NONNULL(1
 
void void void void * BLI_mempool_as_arrayN (BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
void void void void void BLI_mempool_set_memory_debug (void)
 
void BLI_mempool_iternew (BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
 
void * BLI_mempool_iterstep (BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
BLI_mempool_iterBLI_mempool_iter_threadsafe_create (BLI_mempool *pool, const size_t num_iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
void BLI_mempool_iter_threadsafe_free (BLI_mempool_iter *iter_arr) ATTR_NONNULL()
 

Typedef Documentation

◆ BLI_mempool

typedef struct BLI_mempool BLI_mempool

Definition at line 1 of file BLI_mempool.h.

◆ BLI_mempool_iter

iteration stuff. note: this may easy to produce bugs with

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BLI_MEMPOOL_NOP 
BLI_MEMPOOL_ALLOW_ITER 

allow iterating on this mempool.

Note
this requires that the first four bytes of the elements never begin with 'free' (FREEWORD).
order of iteration is only assured to be the order of allocation when no chunks have been freed.

Definition at line 76 of file BLI_mempool.h.

Function Documentation

◆ BLI_mempool_alloc()

void* BLI_mempool_alloc ( BLI_mempool pool)

◆ BLI_mempool_as_array()

void void void BLI_mempool_as_array ( BLI_mempool pool,
void *  data 
)

◆ BLI_mempool_as_arrayN()

void void void void* BLI_mempool_as_arrayN ( BLI_mempool pool,
const char *  allocstr 
)

Referenced by write_space_outliner().

◆ BLI_mempool_as_table()

void BLI_mempool_as_table ( BLI_mempool pool,
void **  data 
)

◆ BLI_mempool_as_tableN()

void void** BLI_mempool_as_tableN ( BLI_mempool pool,
const char *  allocstr 
)

◆ BLI_mempool_calloc()

void* BLI_mempool_calloc ( BLI_mempool pool)

◆ BLI_mempool_clear()

void BLI_mempool_clear ( BLI_mempool pool)

◆ BLI_mempool_clear_ex()

void void BLI_mempool_clear_ex ( BLI_mempool pool,
const int  totelem_reserve 
)

Empty the pool, as if it were just created.

Parameters
poolThe pool to clear.
totelem_reserveOptionally reserve how many items should be kept from clearing.

Definition at line 694 of file BLI_mempool.c.

References mempool_chunk_add(), mempool_chunk_find(), mempool_chunk_free(), mempool_maxchunks(), BLI_mempool_chunk::next, NULL, blender::compositor::pool, VALGRIND_CREATE_MEMPOOL, and VALGRIND_DESTROY_MEMPOOL.

Referenced by BLI_ghash_clear_ex(), BLI_mempool_clear(), and DRW_instance_data_list_resize().

◆ BLI_mempool_create()

BLI_mempool* BLI_mempool_create ( unsigned int  esize,
unsigned int  totelem,
unsigned int  pchunk,
unsigned int  flag 
)

◆ BLI_mempool_destroy()

void BLI_mempool_destroy ( BLI_mempool pool)

◆ BLI_mempool_findelem()

void* BLI_mempool_findelem ( BLI_mempool pool,
unsigned int  index 
)

◆ BLI_mempool_free()

void BLI_mempool_free ( BLI_mempool pool,
void *  addr 
)

◆ BLI_mempool_iter_threadsafe_create()

BLI_mempool_iter* BLI_mempool_iter_threadsafe_create ( BLI_mempool pool,
const size_t  num_iter 
)

Initialize an array of mempool iterators, BLI_MEMPOOL_ALLOW_ITER flag must be set.

This is used in threaded code, to generate as much iterators as needed (each task should have its own), such that each iterator goes over its own single chunk, and only getting the next chunk to iterate over has to be protected against concurrency (which can be done in a lockless way).

To be used when creating a task for each single item in the pool is totally overkill.

See BLI_task_parallel_mempool implementation for detailed usage example.

Definition at line 561 of file BLI_mempool.c.

References BLI_assert, BLI_MEMPOOL_ALLOW_ITER, BLI_mempool_iternew(), BLI_mempool_iter::curchunk, BLI_mempool_iter::curchunk_threaded_shared, MEM_mallocN, NULL, and blender::compositor::pool.

Referenced by BLI_task_parallel_mempool().

◆ BLI_mempool_iter_threadsafe_free()

void BLI_mempool_iter_threadsafe_free ( BLI_mempool_iter iter_arr)

◆ BLI_mempool_iternew()

void BLI_mempool_iternew ( BLI_mempool pool,
BLI_mempool_iter iter 
)

◆ BLI_mempool_iterstep()

void* BLI_mempool_iterstep ( BLI_mempool_iter iter)

◆ BLI_mempool_len()

int BLI_mempool_len ( BLI_mempool pool)

◆ BLI_mempool_set_memory_debug()

void void void void void BLI_mempool_set_memory_debug ( void  )

Definition at line 769 of file BLI_mempool.c.

References mempool_debug_memset.

Referenced by arg_handle_debug_mode_set().