Blender V5.0
BLI_mempool.h File Reference
#include "BLI_compiler_attrs.h"
#include <type_traits>

Go to the source code of this file.

Classes

struct  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 elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void * BLI_mempool_alloc (BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void * BLI_mempool_calloc (BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
template<typename T>
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL (1) T *BLI_mempool_alloc(BLI_mempool *pool)
void BLI_mempool_free (BLI_mempool *pool, void *addr) ATTR_NONNULL(1
void void BLI_mempool_clear_ex (BLI_mempool *pool, int elem_num_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 (const 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_array (BLI_mempool *pool, void *data) ATTR_NONNULL(1
void void * BLI_mempool_as_arrayN (BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void void void BLI_mempool_set_memory_debug ()
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()

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

BLI_mempool.flag

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 101 of file BLI_mempool.h.

Function Documentation

◆ ATTR_NONNULL()

template<typename T>
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL ( 1 )

C++ templates for convenience.

Definition at line 33 of file BLI_mempool.h.

References BLI_mempool_alloc(), and T.

◆ BLI_mempool_alloc()

◆ BLI_mempool_as_array()

void BLI_mempool_as_array ( BLI_mempool * pool,
void * data )

Fill in data with the contents of the mempool.

References data.

◆ BLI_mempool_as_arrayN()

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

A version of BLI_mempool_as_array that allocates and returns the data.

References ATTR_MALLOC, and ATTR_WARN_UNUSED_RESULT.

Referenced by blender::ed::outliner::write_space_outliner().

◆ BLI_mempool_calloc()

◆ BLI_mempool_clear()

void BLI_mempool_clear ( BLI_mempool * pool)

Wrap BLI_mempool_clear_ex with no reserve set.

Definition at line 835 of file BLI_mempool.cc.

References BLI_mempool_clear_ex().

Referenced by BLI_array_store_clear(), bm_uidwalk_clear(), and bmo_planar_faces_exec().

◆ BLI_mempool_clear_ex()

void void BLI_mempool_clear_ex ( BLI_mempool * pool,
int elem_num_reserve )

Empty the pool, as if it were just created.

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

Definition at line 787 of file BLI_mempool.cc.

References BLI_mempool::chunk_tail, BLI_mempool::chunks, BLI_mempool::free, BLI_mempool::maxchunks, mempool_chunk_add(), mempool_chunk_find(), mempool_chunk_free(), mempool_maxchunks(), BLI_mempool_chunk::next, BLI_mempool::pchunk, BLI_mempool::totused, VALGRIND_CREATE_MEMPOOL, and VALGRIND_DESTROY_MEMPOOL.

Referenced by BLI_ghash_clear_ex(), and BLI_mempool_clear().

◆ BLI_mempool_create()

◆ BLI_mempool_destroy()

◆ BLI_mempool_findelem()

◆ BLI_mempool_free()

◆ BLI_mempool_iternew()

◆ BLI_mempool_iterstep()

◆ BLI_mempool_len()

◆ BLI_mempool_set_memory_debug()

void void void BLI_mempool_set_memory_debug ( )

Definition at line 852 of file BLI_mempool.cc.

References mempool_debug_memset.

Referenced by arg_handle_debug_mode_set().