Blender V5.0
BLI_linklist_stack.h File Reference

BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers, using a single linked list allocated from a mempool. More...

#include "BLI_linklist.h"
#include "BLI_mempool.h"

Go to the source code of this file.

Macros

Linked Stack (mempool)

Uses BLI_mempool for storage.

#define BLI_LINKSTACK_DECLARE(var, type)
#define BLI_LINKSTACK_INIT(var)
#define BLI_LINKSTACK_SIZE(var)
#define BLI_LINKSTACK_PUSH(var, ptr)
#define BLI_LINKSTACK_POP(var)
#define BLI_LINKSTACK_POP_DEFAULT(var, r)
#define BLI_LINKSTACK_SWAP(var_a, var_b)
#define BLI_LINKSTACK_FREE(var)
Linked Stack (alloca)

Linked Stack, using stack memory (alloca).

alloca never frees, pop'd items are stored in a free-list for reuse. only use for lists small enough to fit on the stack.

#define _BLI_SMALLSTACK_CAST(var)
#define _BLI_SMALLSTACK_FAKEUSER(var)
#define BLI_SMALLSTACK_DECLARE(var, type)
#define BLI_SMALLSTACK_PUSH(var, data)
#define _BLI_SMALLSTACK_DEL_EX(var_src, var_dst)
#define _BLI_SMALLSTACK_DEL(var)
#define BLI_SMALLSTACK_POP(var)
#define BLI_SMALLSTACK_POP_EX(var_src, var_dst)
#define BLI_SMALLSTACK_PEEK(var)
#define BLI_SMALLSTACK_IS_EMPTY(var)
#define BLI_SMALLSTACK_AS_TABLE(var, data)
#define BLI_SMALLSTACK_ITER_BEGIN(var, item)
#define BLI_SMALLSTACK_ITER_END
#define BLI_SMALLSTACK_SWAP(var_a, var_b)

Detailed Description

BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers, using a single linked list allocated from a mempool.

Note
These macros follow STACK_* macros defined in BLI_utildefines.h and should be kept (mostly) interchangeable.
_##var##_type is a dummy variable only used for type-checks.

Definition in file BLI_linklist_stack.h.

Macro Definition Documentation

◆ _BLI_SMALLSTACK_CAST

#define _BLI_SMALLSTACK_CAST ( var)

Definition at line 84 of file BLI_linklist_stack.h.

◆ _BLI_SMALLSTACK_DEL

#define _BLI_SMALLSTACK_DEL ( var)
Value:

Definition at line 119 of file BLI_linklist_stack.h.

◆ _BLI_SMALLSTACK_DEL_EX

#define _BLI_SMALLSTACK_DEL_EX ( var_src,
var_dst )
Value:
(void)(_BLI_SMALLSTACK_FAKEUSER(var_src), \
(_##var_src##_temp = _##var_src##_stack->next), \
(_##var_src##_stack->next = _##var_dst##_free), \
(_##var_dst##_free = _##var_src##_stack), \
(_##var_src##_stack = _##var_src##_temp))

Definition at line 111 of file BLI_linklist_stack.h.

◆ _BLI_SMALLSTACK_FAKEUSER

#define _BLI_SMALLSTACK_FAKEUSER ( var)
Value:
(void)(&(_##var##_type))

Definition at line 87 of file BLI_linklist_stack.h.

◆ BLI_LINKSTACK_DECLARE

◆ BLI_LINKSTACK_FREE

◆ BLI_LINKSTACK_INIT

◆ BLI_LINKSTACK_POP

◆ BLI_LINKSTACK_POP_DEFAULT

#define BLI_LINKSTACK_POP_DEFAULT ( var,
r )
Value:
(decltype(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : r)

Definition at line 45 of file BLI_linklist_stack.h.

◆ BLI_LINKSTACK_PUSH

◆ BLI_LINKSTACK_SIZE

◆ BLI_LINKSTACK_SWAP

#define BLI_LINKSTACK_SWAP ( var_a,
var_b )

◆ BLI_SMALLSTACK_AS_TABLE

#define BLI_SMALLSTACK_AS_TABLE ( var,
data )
Value:
{ \
LinkNode *_##var##_iter; \
unsigned int i; \
for (_##var##_iter = _##var##_stack, i = 0; _##var##_iter; \
_##var##_iter = _##var##_iter->next, i++) \
{ \
*(void **)&(data)[i] = _##var##_iter->link; \
} \
} \
((void)0)
BMesh const char void * data
i
Definition text_draw.cc:230

Definition at line 139 of file BLI_linklist_stack.h.

Referenced by bmesh_kernel_vert_separate().

◆ BLI_SMALLSTACK_DECLARE

◆ BLI_SMALLSTACK_IS_EMPTY

#define BLI_SMALLSTACK_IS_EMPTY ( var)

◆ BLI_SMALLSTACK_ITER_BEGIN

#define BLI_SMALLSTACK_ITER_BEGIN ( var,
item )
Value:
{ \
LinkNode *_##var##_iter; \
for (_##var##_iter = _##var##_stack; _##var##_iter; _##var##_iter = _##var##_iter->next) { \
item = _BLI_SMALLSTACK_CAST(var)(_##var##_iter->link);

Definition at line 152 of file BLI_linklist_stack.h.

◆ BLI_SMALLSTACK_ITER_END

#define BLI_SMALLSTACK_ITER_END
Value:
} \
} \
(void)0

Definition at line 158 of file BLI_linklist_stack.h.

◆ BLI_SMALLSTACK_PEEK

#define BLI_SMALLSTACK_PEEK ( var)
Value:
(_BLI_SMALLSTACK_CAST(var)((_##var##_stack) ? _##var##_stack->link : NULL))

Definition at line 133 of file BLI_linklist_stack.h.

◆ BLI_SMALLSTACK_POP

◆ BLI_SMALLSTACK_POP_EX

#define BLI_SMALLSTACK_POP_EX ( var_src,
var_dst )
Value:
(_##var_src##_stack) ? \
(_BLI_SMALLSTACK_DEL_EX(var_src, var_dst), (_##var_dst##_free->link)) : \
NULL))

Definition at line 127 of file BLI_linklist_stack.h.

Referenced by bm_face_split_by_edges(), and bm_face_split_edgenet_find_loop_walk().

◆ BLI_SMALLSTACK_PUSH

#define BLI_SMALLSTACK_PUSH ( var,
data )
Value:
{ \
CHECK_TYPE_PAIR(data, _##var##_type); \
if (_##var##_free) { \
_##var##_temp = _##var##_free; \
_##var##_free = _##var##_free->next; \
} \
else { \
_##var##_temp = (LinkNode *)alloca(sizeof(LinkNode)); \
} \
_##var##_temp->next = _##var##_stack; \
_##var##_temp->link = data; \
_##var##_stack = _##var##_temp; \
_BLI_SMALLSTACK_FAKEUSER(var); \
} \
(void)0

Definition at line 93 of file BLI_linklist_stack.h.

Referenced by bm_face_split_by_edges(), bm_face_split_edge_find(), BM_face_split_edgenet_connect_islands(), bm_face_split_edgenet_find_connection(), bm_face_split_edgenet_find_loop_pair(), bm_face_split_edgenet_find_loop_walk(), bm_face_split_edgenet_partial_connect(), bm_mesh_loops_assign_normal_data(), bm_mesh_loops_calc_normals_for_loop(), bmesh_kernel_join_edge_kill_vert(), bmesh_kernel_join_vert_kill_edge(), bmesh_kernel_vert_separate(), edbm_average_normals_exec(), edbm_face_split_by_edges_exec(), normals_merge(), normals_split(), and uv_rip_pairs_from_loop().

◆ BLI_SMALLSTACK_SWAP

#define BLI_SMALLSTACK_SWAP ( var_a,
var_b )
Value:
{ \
CHECK_TYPE_PAIR(_##var_a##_type, _##var_b##_type); \
SWAP(LinkNode *, _##var_a##_stack, _##var_b##_stack); \
SWAP(LinkNode *, _##var_a##_free, _##var_b##_free); \
} \
(void)0

Definition at line 163 of file BLI_linklist_stack.h.

Referenced by bm_face_split_by_edges(), bm_face_split_edgenet_find_loop_pair(), and bm_face_split_edgenet_find_loop_walk().