27 if (src->
first ==
nullptr) {
31 if (dst->
first ==
nullptr) {
45 if (src->
first ==
nullptr) {
49 if (dst->
first ==
nullptr) {
67 if (vlink == original_listbase->
last) {
72 if (vlink ==
nullptr) {
74 std::swap(*original_listbase, *split_listbase);
78 Link *link =
static_cast<Link *
>(vlink);
81 Link *last_link =
static_cast<Link *
>(original_listbase->
last);
83 original_listbase->
last = link;
84 split_listbase->
first = next_link;
85 split_listbase->
last = last_link;
88 next_link->
prev =
nullptr;
93 Link *link =
static_cast<Link *
>(vlink);
95 if (link ==
nullptr) {
100 link->
prev =
nullptr;
102 if (listbase->
first) {
105 if (listbase->
last ==
nullptr) {
106 listbase->
last = link;
108 listbase->
first = link;
113 Link *link =
static_cast<Link *
>(vlink);
115 if (link ==
nullptr) {
119 link->
next =
nullptr;
122 if (listbase->
last) {
123 ((
Link *)listbase->
last)->next = link;
125 if (listbase->
first ==
nullptr) {
126 listbase->
first = link;
128 listbase->
last = link;
133 Link *link =
static_cast<Link *
>(vlink);
135 if (link ==
nullptr) {
146 if (listbase->
last == link) {
149 if (listbase->
first == link) {
166 Link *linka =
static_cast<Link *
>(vlinka);
167 Link *linkb =
static_cast<Link *
>(vlinkb);
169 if (!linka || !linkb) {
173 if (linkb->
next == linka) {
174 std::swap(linka, linkb);
177 if (linka->
next == linkb) {
184 std::swap(linka->
prev, linkb->
prev);
185 std::swap(linka->
next, linkb->
next);
202 if (listbase->
last == linka) {
203 listbase->
last = linkb;
205 else if (listbase->
last == linkb) {
206 listbase->
last = linka;
209 if (listbase->
first == linka) {
210 listbase->
first = linkb;
212 else if (listbase->
first == linkb) {
213 listbase->
first = linka;
219 Link *linka =
static_cast<Link *
>(vlinka);
220 Link *linkb =
static_cast<Link *
>(vlinkb);
221 Link linkc = {
nullptr};
223 if (!linka || !linkb) {
228#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
229# pragma GCC diagnostic push
230# pragma GCC diagnostic ignored "-Wdangling-pointer"
236#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 1201
237# pragma GCC diagnostic pop
272 Link *link =
static_cast<Link *
>(vlink);
274 if (link ==
nullptr) {
287 Link *prev =
nullptr;
288 listbase->
first = iter;
292 }
while ((iter = iter->
next));
293 listbase->
last = prev;
296#define SORT_IMPL_LINKTYPE Link
299#define SORT_IMPL_FUNC listbase_sort_fn
304#define SORT_IMPL_USE_THUNK
305#define SORT_IMPL_FUNC listbase_sort_fn_r
308#undef SORT_IMPL_USE_THUNK
310#undef SORT_IMPL_LINKTYPE
316 head = listbase_sort_fn(head, cmp);
322 int (*cmp)(
void *,
const void *,
const void *),
327 head = listbase_sort_fn_r(head, cmp, thunk);
334 Link *prevlink =
static_cast<Link *
>(vprevlink);
335 Link *newlink =
static_cast<Link *
>(vnewlink);
338 if (newlink ==
nullptr) {
343 if (listbase->
first ==
nullptr) {
344 listbase->
first = newlink;
345 listbase->
last = newlink;
350 if (prevlink ==
nullptr) {
351 newlink->
prev =
nullptr;
354 listbase->
first = newlink;
359 if (listbase->
last == prevlink) {
360 listbase->
last = newlink;
364 newlink->
prev = prevlink;
365 prevlink->
next = newlink;
373 Link *nextlink =
static_cast<Link *
>(vnextlink);
374 Link *newlink =
static_cast<Link *
>(vnewlink);
377 if (newlink ==
nullptr) {
382 if (listbase->
first ==
nullptr) {
383 listbase->
first = newlink;
384 listbase->
last = newlink;
389 if (nextlink ==
nullptr) {
391 newlink->
next =
nullptr;
393 listbase->
last = newlink;
398 if (listbase->
first == nextlink) {
399 listbase->
first = newlink;
402 newlink->
next = nextlink;
404 nextlink->
prev = newlink;
412 Link *l_old =
static_cast<Link *
>(vreplacelink);
413 Link *l_new =
static_cast<Link *
>(vnewlink);
416 if (l_old->
next !=
nullptr) {
419 if (l_old->
prev !=
nullptr) {
428 if (listbase->
first == l_old) {
429 listbase->
first = l_new;
431 if (listbase->
last == l_old) {
432 listbase->
last = l_new;
438 Link *link =
static_cast<Link *
>(vlink);
440 const bool is_up =
step < 0;
448 const int abs_step =
abs(
step);
449 for (
int i = 0;
i < abs_step;
i++) {
450 hook = is_up ? hook->
prev : hook->
next;
487 link =
static_cast<Link *
>(listbase->
first);
501 link =
static_cast<Link *
>(listbase->
first);
516 for (link =
static_cast<Link *
>(listbase->
first); link &&
count != count_max; link = link->
next)
536 Link *link =
nullptr;
539 link =
static_cast<Link *
>(listbase->
first);
540 while (link !=
nullptr && number != 0) {
551 Link *link =
nullptr;
554 link =
static_cast<Link *
>(listbase->
last);
555 while (link !=
nullptr && number != 0) {
566 Link *link =
nullptr;
570 while (link !=
nullptr &&
step != 0) {
577 while (link !=
nullptr &&
step != 0) {
588 Link *link =
nullptr;
591 if (vlink ==
nullptr) {
595 link =
static_cast<Link *
>(listbase->
first);
617 id_iter = ((
const char *)link) + offset;
619 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
630 const char *id_iter = ((
const char *)link) + offset;
631 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
641 for (link = link->
next; link; link = link->
next) {
642 const char *id_iter = ((
const char *)link) + offset;
643 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
658 id_iter = *((
const char **)(((
const char *)link) + offset));
659 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
675 id_iter = *((
const char **)(((
const char *)link) + offset));
676 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
688 for (link = link->
next; link; link = link->
next) {
691 id_iter = *((
const char **)(((
const char *)link) + offset));
692 if (id_iter &&
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
704 const void *ptr_iter = *((
const void **)(((
const char *)link) + offset));
705 if (
ptr == ptr_iter) {
716 const void *ptr_iter = *((
const void **)(((
const char *)link) + offset));
718 if (
ptr == ptr_iter) {
727 const size_t bytes_size,
731 const void *ptr_iter = (
const void *)(((
const char *)link) + offset);
732 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
741 const size_t bytes_size,
746 const void *ptr_iter = (
const void *)(((
const char *)link) + offset);
747 if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
756 const size_t string_offset,
759 Link *link =
nullptr;
760 Link *link_at_index =
nullptr;
763 for (link =
static_cast<Link *
>(listbase->
first), index_iter = 0; link;
764 link = link->
next, index_iter++)
766 if (
string !=
nullptr &&
string[0] !=
'\0') {
767 const char *string_iter = ((
const char *)link) + string_offset;
769 if (
string[0] == string_iter[0] &&
STREQ(
string, string_iter)) {
773 if (index_iter == index) {
774 link_at_index = link;
777 return link_at_index;
782 Link *link =
nullptr;
786 link =
static_cast<Link *
>(listbase->
first);
788 id_iter = ((
const char *)link) + offset;
790 if (
id[0] == id_iter[0] &&
STREQ(
id, id_iter)) {
802 ListBase list = {some_link, some_link};
803 if (some_link ==
nullptr) {
808 while (((
Link *)list.
first)->prev !=
nullptr) {
813 while (((
Link *)list.
last)->next !=
nullptr) {
822 Link *dst_link, *src_link;
825 src_link =
static_cast<Link *
>(src->
first);
832 src_link = src_link->
next;
839 Link *prev =
nullptr;
883 if (lb->
first ==
nullptr && lb->
last ==
nullptr) {
895 if (lb_link == lb->
first) {
896 if (lb_link->prev !=
nullptr) {
900 if (lb_link == lb->
last) {
901 if (lb_link->next !=
nullptr) {
907 if (lb_link == lb->
last) {
908 if (lb_link->next !=
nullptr) {
912 if (lb_link == lb->
first) {
913 if (lb_link->prev !=
nullptr) {
926 if (
data ==
nullptr) {
void BLI_kdtree_nd_ free(KDTree *tree)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
These structs are the foundation for all linked lists in the library system.
Read Guarded memory(de)allocation.
BMesh const char void * data
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
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_listbase_findafter_string(Link *link, const char *id, const int offset)
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_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)