25#define LISTBASE_FOREACH(type, var, list) \
26 for (type var = (type)((list)->first_); var != nullptr; var = (type)(((Link *)(var))->next))
27#define LISTBASE_FOREACH_BACKWARD(type, var, list) \
28 for (type var = (type)((list)->last_); var != nullptr; var = (type)(((Link *)(var))->prev))
34 if (src->
first_ ==
nullptr) {
38 if (dst->
first_ ==
nullptr) {
52 if (src->
first_ ==
nullptr) {
56 if (dst->
first_ ==
nullptr) {
74 if (vlink == original_listbase->
last_) {
79 if (vlink ==
nullptr) {
81 std::swap(*original_listbase, *split_listbase);
85 Link *link =
static_cast<Link *
>(vlink);
88 Link *last_link =
static_cast<Link *
>(original_listbase->
last_);
90 original_listbase->
last_ = link;
91 split_listbase->
first_ = next_link;
92 split_listbase->
last_ = last_link;
95 next_link->
prev =
nullptr;
100 Link *link =
static_cast<Link *
>(vlink);
102 if (link ==
nullptr) {
107 link->
prev =
nullptr;
110 (
static_cast<Link *
>(listbase->
first_))->prev = link;
112 if (listbase->
last_ ==
nullptr) {
113 listbase->
last_ = link;
120 Link *link =
static_cast<Link *
>(vlink);
122 if (link ==
nullptr) {
126 link->
next =
nullptr;
129 if (listbase->
last_) {
130 (
static_cast<Link *
>(listbase->
last_))->next = link;
132 if (listbase->
first_ ==
nullptr) {
135 listbase->
last_ = link;
140 Link *link =
static_cast<Link *
>(vlink);
142 if (link ==
nullptr) {
153 if (listbase->
last_ == link) {
156 if (listbase->
first_ == link) {
173 Link *linka =
static_cast<Link *
>(vlinka);
174 Link *linkb =
static_cast<Link *
>(vlinkb);
176 if (!linka || !linkb) {
180 if (linkb->
next == linka) {
181 std::swap(linka, linkb);
184 if (linka->
next == linkb) {
191 std::swap(linka->
prev, linkb->
prev);
192 std::swap(linka->
next, linkb->
next);
209 if (listbase->
last_ == linka) {
210 listbase->
last_ = linkb;
212 else if (listbase->
last_ == linkb) {
213 listbase->
last_ = linka;
216 if (listbase->
first_ == linka) {
219 else if (listbase->
first_ == linkb) {
226 Link *linka =
static_cast<Link *
>(vlinka);
227 Link *linkb =
static_cast<Link *
>(vlinkb);
228 Link linkc = {
nullptr};
230 if (!linka || !linkb) {
235#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
236# pragma GCC diagnostic push
237# pragma GCC diagnostic ignored "-Wdangling-pointer"
243#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
244# pragma GCC diagnostic pop
279 Link *link =
static_cast<Link *
>(vlink);
281 if (link ==
nullptr) {
294 Link *prev =
nullptr;
299 }
while ((iter = iter->
next));
300 listbase->
last_ = prev;
303#define SORT_IMPL_LINKTYPE Link
306#define SORT_IMPL_FUNC listbase_sort_fn
311#define SORT_IMPL_USE_THUNK
312#define SORT_IMPL_FUNC listbase_sort_fn_r
315#undef SORT_IMPL_USE_THUNK
317#undef SORT_IMPL_LINKTYPE
323 head = listbase_sort_fn(head, cmp);
329 int (*cmp)(
void *,
const void *,
const void *),
334 head = listbase_sort_fn_r(head, cmp, thunk);
341 Link *prevlink =
static_cast<Link *
>(vprevlink);
342 Link *newlink =
static_cast<Link *
>(vnewlink);
345 if (newlink ==
nullptr) {
350 if (listbase->
first_ ==
nullptr) {
351 listbase->
first_ = newlink;
352 listbase->
last_ = newlink;
357 if (prevlink ==
nullptr) {
358 newlink->
prev =
nullptr;
361 listbase->
first_ = newlink;
366 if (listbase->
last_ == prevlink) {
367 listbase->
last_ = newlink;
371 newlink->
prev = prevlink;
372 prevlink->
next = newlink;
380 Link *nextlink =
static_cast<Link *
>(vnextlink);
381 Link *newlink =
static_cast<Link *
>(vnewlink);
384 if (newlink ==
nullptr) {
389 if (listbase->
first_ ==
nullptr) {
390 listbase->
first_ = newlink;
391 listbase->
last_ = newlink;
396 if (nextlink ==
nullptr) {
398 newlink->
next =
nullptr;
399 (
static_cast<Link *
>(listbase->
last_))->next = newlink;
400 listbase->
last_ = newlink;
405 if (listbase->
first_ == nextlink) {
406 listbase->
first_ = newlink;
409 newlink->
next = nextlink;
411 nextlink->
prev = newlink;
419 Link *l_old =
static_cast<Link *
>(vreplacelink);
420 Link *l_new =
static_cast<Link *
>(vnewlink);
423 if (l_old->
next !=
nullptr) {
426 if (l_old->
prev !=
nullptr) {
435 if (listbase->
first_ == l_old) {
438 if (listbase->
last_ == l_old) {
439 listbase->
last_ = l_new;
445 Link *link =
static_cast<Link *
>(vlink);
447 const bool is_up =
step < 0;
455 const int abs_step =
abs(
step);
456 for (
int i = 0; i < abs_step; i++) {
457 hook = is_up ? hook->
prev : hook->
next;
523 for (link =
static_cast<Link *
>(listbase->
first_); link && count != count_max; link = link->
next)
543 Link *link =
nullptr;
547 while (link !=
nullptr && number != 0) {
558 Link *link =
nullptr;
561 link =
static_cast<Link *
>(listbase->
last_);
562 while (link !=
nullptr && number != 0) {
573 Link *link =
nullptr;
577 while (link !=
nullptr &&
step != 0) {
584 while (link !=
nullptr &&
step != 0) {
595 Link *link =
nullptr;
598 if (vlink ==
nullptr) {
624 id_iter = (
reinterpret_cast<const char *
>(link)) + offset;
626 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
637 const char *id_iter = (
reinterpret_cast<const char *
>(link)) + offset;
638 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
648 for (link = link->
next; link; link = link->
next) {
649 const char *id_iter = (
reinterpret_cast<const char *
>(link)) + offset;
650 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
665 id_iter = *(
reinterpret_cast<const char **
>(
666 const_cast<char *
>(((
reinterpret_cast<const char *
>(link)) + offset))));
667 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
683 id_iter = *(
reinterpret_cast<const char **
>(
684 const_cast<char *
>(((
reinterpret_cast<const char *
>(link)) + offset))));
685 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
697 for (link = link->
next; link; link = link->
next) {
700 id_iter = *(
reinterpret_cast<const char **
>(
701 const_cast<char *
>(((
reinterpret_cast<const char *
>(link)) + offset))));
702 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
714 const void *ptr_iter = *(
reinterpret_cast<const void **
>(
715 const_cast<char *
>(((
reinterpret_cast<const char *
>(link)) + offset))));
716 if (ptr == ptr_iter) {
727 const void *ptr_iter = *(
reinterpret_cast<const void **
>(
728 const_cast<char *
>(((
reinterpret_cast<const char *
>(link)) + offset))));
730 if (ptr == ptr_iter) {
739 const size_t bytes_size,
743 const void *ptr_iter =
static_cast<const void *
>((
reinterpret_cast<const char *
>(link)) +
745 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
754 const size_t bytes_size,
759 const void *ptr_iter =
static_cast<const void *
>((
reinterpret_cast<const char *
>(link)) +
761 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
770 const size_t string_offset,
773 Link *link =
nullptr;
774 Link *link_at_index =
nullptr;
777 for (link =
static_cast<Link *
>(listbase->
first_), index_iter = 0; link;
778 link = link->
next, index_iter++)
780 if (
string !=
nullptr &&
string[0] !=
'\0') {
781 const char *string_iter = (
reinterpret_cast<const char *
>(link)) + string_offset;
783 if (
string[0] == string_iter[0] &&
STREQ(
string, string_iter)) {
787 if (index_iter ==
index) {
788 link_at_index = link;
791 return link_at_index;
796 Link *link =
nullptr;
802 id_iter = (
reinterpret_cast<const char *
>(link)) + offset;
804 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
817 if (some_link ==
nullptr) {
822 while ((
static_cast<Link *
>(
list.first_))->prev !=
nullptr) {
827 while ((
static_cast<Link *
>(
list.last_))->next !=
nullptr) {
836 Link *dst_link, *src_link;
843 dst_link = MEM_dupalloc(src_link);
846 src_link = src_link->
next;
853 Link *prev =
nullptr;
854 Link *next =
nullptr;
876 lb->
last_ = (
static_cast<Link *
>(vlink))->prev;
878 (
static_cast<Link *
>(lb->
first_))->prev =
nullptr;
879 (
static_cast<Link *
>(lb->
last_))->next =
nullptr;
888 lb->
first_ = (
static_cast<Link *
>(vlink))->next;
891 (
static_cast<Link *
>(lb->
first_))->prev =
nullptr;
892 (
static_cast<Link *
>(lb->
last_))->next =
nullptr;
897 if (lb->
first_ ==
nullptr && lb->
last_ ==
nullptr) {
909 if (lb_link == lb->
first_) {
910 if (lb_link->prev !=
nullptr) {
914 if (lb_link == lb->
last_) {
915 if (lb_link->next !=
nullptr) {
921 if (lb_link == lb->
last_) {
922 if (lb_link->next !=
nullptr) {
926 if (lb_link == lb->
first_) {
927 if (lb_link->prev !=
nullptr) {
940 if (
data ==
nullptr) {
These structs are the foundation for all linked lists in the library system.
Read Blender memory allocation and freeing.
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
void free(Subdiv *subdiv)
void * BLI_findptr(const ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void void BLI_listbases_swaplinks(ListBase *listbasea, ListBase *listbaseb, void *vlinka, void *vlinkb) ATTR_NONNULL(2
void * BLI_rfindlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_poptail(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink) ATTR_NONNULL(1
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
void * BLI_rfindstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_listbase_findafter_string(Link *link, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void BLI_listbase_rotate_last(ListBase *lb, void *vlink) ATTR_NONNULL(1
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
bool BLI_listbase_validate(ListBase *lb)
void * BLI_findlinkfrom(Link *start, int step) ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findstringindex(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring_ptr(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_freelist(ListBase *listbase) ATTR_NONNULL(1)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void void void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1
void * BLI_rfindstring_ptr(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_listbase_bytes_rfind(const ListBase *listbase, const void *bytes, size_t bytes_size, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
BMesh const char void * data
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void void void void void BLI_listbase_split_after(ListBase *original_listbase, ListBase *split_listbase, void *vlink) ATTR_NONNULL(1
bool BLI_listbase_move_index(ListBase *listbase, int from, int to) ATTR_NONNULL()
void * BLI_listbase_findafter_string_ptr(Link *link, const char *id, int offset)
void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb) ATTR_NONNULL(1
void BLI_listbase_rotate_first(ListBase *lb, void *vlink) ATTR_NONNULL(1
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
LinkData * BLI_genericNodeN(void *data)
static void listbase_double_from_single(Link *iter, ListBase *listbase)
void * BLI_rfindptr(const ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void void void void void BLI_listbase_reverse(ListBase *lb) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count_at_most(const ListBase *listbase, int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
void void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void void * BLI_listbase_string_or_index_find(const ListBase *listbase, const char *string, size_t string_offset, int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_listbase_bytes_find(const ListBase *listbase, const void *bytes, size_t bytes_size, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
bool BLI_remlink_safe(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void BLI_movelisttolist_reverse(ListBase *dst, ListBase *src) ATTR_NONNULL(1
ListBase BLI_listbase_from_link(Link *some_link)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()