26 if (src->
first ==
nullptr) {
30 if (dst->
first ==
nullptr) {
44 if (src->
first ==
nullptr) {
48 if (dst->
first ==
nullptr) {
66 if (vlink == original_listbase->
last) {
71 if (vlink ==
nullptr) {
73 std::swap(*original_listbase, *split_listbase);
77 Link *link =
static_cast<Link *
>(vlink);
80 Link *last_link =
static_cast<Link *
>(original_listbase->
last);
82 original_listbase->
last = link;
83 split_listbase->
first = next_link;
84 split_listbase->
last = last_link;
87 next_link->
prev =
nullptr;
92 Link *link =
static_cast<Link *
>(vlink);
94 if (link ==
nullptr) {
101 if (listbase->
first) {
104 if (listbase->
last ==
nullptr) {
105 listbase->
last = link;
107 listbase->
first = link;
112 Link *link =
static_cast<Link *
>(vlink);
114 if (link ==
nullptr) {
118 link->
next =
nullptr;
121 if (listbase->
last) {
124 if (listbase->
first ==
nullptr) {
125 listbase->
first = link;
127 listbase->
last = link;
132 Link *link =
static_cast<Link *
>(vlink);
134 if (link ==
nullptr) {
145 if (listbase->
last == link) {
148 if (listbase->
first == link) {
165 Link *linka =
static_cast<Link *
>(vlinka);
166 Link *linkb =
static_cast<Link *
>(vlinkb);
168 if (!linka || !linkb) {
172 if (linkb->
next == linka) {
173 std::swap(linka, linkb);
176 if (linka->
next == linkb) {
183 std::swap(linka->
prev, linkb->
prev);
184 std::swap(linka->
next, linkb->
next);
201 if (listbase->
last == linka) {
202 listbase->
last = linkb;
204 else if (listbase->
last == linkb) {
205 listbase->
last = linka;
208 if (listbase->
first == linka) {
209 listbase->
first = linkb;
211 else if (listbase->
first == linkb) {
212 listbase->
first = linka;
218 Link *linka =
static_cast<Link *
>(vlinka);
219 Link *linkb =
static_cast<Link *
>(vlinkb);
220 Link linkc = {
nullptr};
222 if (!linka || !linkb) {
227#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
228# pragma GCC diagnostic push
229# pragma GCC diagnostic ignored "-Wdangling-pointer"
235#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
236# pragma GCC diagnostic pop
254 if ((link =
static_cast<Link *
>(listbase->
first))) {
263 if ((link =
static_cast<Link *
>(listbase->
last))) {
271 Link *link =
static_cast<Link *
>(vlink);
273 if (link ==
nullptr) {
286 Link *prev =
nullptr;
287 listbase->
first = iter;
291 }
while ((iter = iter->
next));
292 listbase->
last = prev;
295#define SORT_IMPL_LINKTYPE Link
298#define SORT_IMPL_FUNC listbase_sort_fn
303#define SORT_IMPL_USE_THUNK
304#define SORT_IMPL_FUNC listbase_sort_fn_r
307#undef SORT_IMPL_USE_THUNK
309#undef SORT_IMPL_LINKTYPE
315 head = listbase_sort_fn(head, cmp);
321 int (*cmp)(
void *,
const void *,
const void *),
326 head = listbase_sort_fn_r(head, cmp, thunk);
333 Link *prevlink =
static_cast<Link *
>(vprevlink);
334 Link *newlink =
static_cast<Link *
>(vnewlink);
337 if (newlink ==
nullptr) {
342 if (listbase->
first ==
nullptr) {
343 listbase->
first = newlink;
344 listbase->
last = newlink;
349 if (prevlink ==
nullptr) {
350 newlink->
prev =
nullptr;
353 listbase->
first = newlink;
358 if (listbase->
last == prevlink) {
359 listbase->
last = newlink;
363 newlink->
prev = prevlink;
364 prevlink->
next = newlink;
372 Link *nextlink =
static_cast<Link *
>(vnextlink);
373 Link *newlink =
static_cast<Link *
>(vnewlink);
376 if (newlink ==
nullptr) {
381 if (listbase->
first ==
nullptr) {
382 listbase->
first = newlink;
383 listbase->
last = newlink;
388 if (nextlink ==
nullptr) {
390 newlink->
next =
nullptr;
392 listbase->
last = newlink;
397 if (listbase->
first == nextlink) {
398 listbase->
first = newlink;
401 newlink->
next = nextlink;
403 nextlink->
prev = newlink;
411 Link *l_old =
static_cast<Link *
>(vreplacelink);
412 Link *l_new =
static_cast<Link *
>(vnewlink);
415 if (l_old->
next !=
nullptr) {
418 if (l_old->
prev !=
nullptr) {
427 if (listbase->
first == l_old) {
428 listbase->
first = l_new;
430 if (listbase->
last == l_old) {
431 listbase->
last = l_new;
437 Link *link =
static_cast<Link *
>(vlink);
439 const bool is_up = step < 0;
447 const int abs_step =
abs(step);
448 for (
int i = 0; i < abs_step; i++) {
449 hook = is_up ? hook->
prev : hook->
next;
486 link =
static_cast<Link *
>(listbase->
first);
500 link =
static_cast<Link *
>(listbase->
first);
515 for (link =
static_cast<Link *
>(listbase->
first); link &&
count != count_max; link = link->
next)
535 Link *link =
nullptr;
538 link =
static_cast<Link *
>(listbase->
first);
539 while (link !=
nullptr && number != 0) {
550 Link *link =
nullptr;
553 link =
static_cast<Link *
>(listbase->
last);
554 while (link !=
nullptr && number != 0) {
565 Link *link =
nullptr;
569 while (link !=
nullptr && step != 0) {
576 while (link !=
nullptr && step != 0) {
587 Link *link =
nullptr;
590 if (vlink ==
nullptr) {
594 link =
static_cast<Link *
>(listbase->
first);
616 id_iter = ((
const char *)link) + offset;
618 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
629 const char *id_iter = ((
const char *)link) + offset;
630 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
645 id_iter = *((
const char **)(((
const char *)link) + offset));
646 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
662 id_iter = *((
const char **)(((
const char *)link) + offset));
663 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
675 for (link = link->
next; link; link = link->
next) {
678 id_iter = *((
const char **)(((
const char *)link) + offset));
679 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
691 const void *ptr_iter = *((
const void **)(((
const char *)link) + offset));
692 if (
ptr == ptr_iter) {
703 const void *ptr_iter = *((
const void **)(((
const char *)link) + offset));
705 if (
ptr == ptr_iter) {
714 const size_t bytes_size,
718 const void *ptr_iter = (
const void *)(((
const char *)link) + offset);
719 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
728 const size_t bytes_size,
733 const void *ptr_iter = (
const void *)(((
const char *)link) + offset);
734 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
743 const size_t string_offset,
746 Link *link =
nullptr;
747 Link *link_at_index =
nullptr;
750 for (link =
static_cast<Link *
>(listbase->
first), index_iter = 0; link;
751 link = link->
next, index_iter++)
753 if (
string !=
nullptr &&
string[0] !=
'\0') {
754 const char *string_iter = ((
const char *)link) + string_offset;
756 if (
string[0] == string_iter[0] &&
STREQ(
string, string_iter)) {
760 if (index_iter == index) {
761 link_at_index = link;
764 return link_at_index;
769 Link *link =
nullptr;
773 link =
static_cast<Link *
>(listbase->
first);
775 id_iter = ((
const char *)link) + offset;
777 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
789 ListBase list = {some_link, some_link};
790 if (some_link ==
nullptr) {
795 while (((
Link *)list.first)->prev !=
nullptr) {
796 list.first = ((
Link *)list.first)->
prev;
800 while (((
Link *)list.last)->
next !=
nullptr) {
801 list.last = ((
Link *)list.last)->
next;
809 Link *dst_link, *src_link;
812 src_link =
static_cast<Link *
>(src->
first);
819 src_link = src_link->
next;
826 Link *prev =
nullptr;
870 if (lb->
first ==
nullptr && lb->
last ==
nullptr) {
882 if (lb_link == lb->
first) {
883 if (lb_link->prev !=
nullptr) {
887 if (lb_link == lb->
last) {
888 if (lb_link->next !=
nullptr) {
894 if (lb_link == lb->
last) {
895 if (lb_link->next !=
nullptr) {
899 if (lb_link == lb->
first) {
900 if (lb_link->prev !=
nullptr) {
913 if (data ==
nullptr) {
918 ld = MEM_cnew<LinkData>(__func__);
void BLI_kdtree_nd_ free(KDTree *tree)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
These structs are the foundation for all linked lists in the library system.
Read Guarded memory(de)allocation.
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink)
void BLI_remlink(ListBase *listbase, void *vlink)
void * BLI_findlinkfrom(Link *start, int step)
void BLI_listbase_rotate_last(ListBase *lb, void *vlink)
bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step)
void BLI_listbase_reverse(ListBase *lb)
void BLI_movelisttolist_reverse(ListBase *dst, ListBase *src)
LinkData * BLI_genericNodeN(void *data)
void * BLI_rfindptr(const ListBase *listbase, const void *ptr, const int offset)
void BLI_freelist(ListBase *listbase)
void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk)
bool BLI_listbase_move_index(ListBase *listbase, int from, int to)
void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink)
void * BLI_listbase_bytes_find(const ListBase *listbase, const void *bytes, const size_t bytes_size, const int offset)
void BLI_addhead(ListBase *listbase, void *vlink)
void BLI_movelisttolist(ListBase *dst, ListBase *src)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
int BLI_findindex(const ListBase *listbase, const void *vlink)
void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *))
void * BLI_poptail(ListBase *listbase)
void * BLI_listbase_findafter_string_ptr(Link *link, const char *id, const int offset)
void BLI_duplicatelist(ListBase *dst, const ListBase *src)
void * BLI_findstring(const ListBase *listbase, const char *id, const int offset)
void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
int BLI_listbase_count(const ListBase *listbase)
void * BLI_listbase_bytes_rfind(const ListBase *listbase, const void *bytes, const size_t bytes_size, const int offset)
void * BLI_findptr(const ListBase *listbase, const void *ptr, const int offset)
void * BLI_rfindstring(const ListBase *listbase, const char *id, const int offset)
void BLI_listbase_split_after(ListBase *original_listbase, ListBase *split_listbase, void *vlink)
void BLI_listbases_swaplinks(ListBase *listbasea, ListBase *listbaseb, void *vlinka, void *vlinkb)
void BLI_freelinkN(ListBase *listbase, void *vlink)
int BLI_findstringindex(const ListBase *listbase, const char *id, const int offset)
void BLI_freelistN(ListBase *listbase)
ListBase BLI_listbase_from_link(Link *some_link)
void * BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int offset)
void BLI_addtail(ListBase *listbase, void *vlink)
void * BLI_pophead(ListBase *listbase)
void * BLI_findlink(const ListBase *listbase, int number)
static void listbase_double_from_single(Link *iter, ListBase *listbase)
void * BLI_listbase_string_or_index_find(const ListBase *listbase, const char *string, const size_t string_offset, const int index)
void BLI_listbase_rotate_first(ListBase *lb, void *vlink)
void * BLI_rfindlink(const ListBase *listbase, int number)
bool BLI_remlink_safe(ListBase *listbase, void *vlink)
bool BLI_listbase_validate(ListBase *lb)
void * BLI_findstring_ptr(const ListBase *listbase, const char *id, const int offset)
int BLI_listbase_count_at_most(const ListBase *listbase, const int count_max)
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
ccl_device_inline int abs(int x)