diff options
Diffstat (limited to 'source/blender/blenlib/intern/listbase.c')
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index cec2fdd5faf..df1fb1148e6 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -68,6 +68,26 @@ void BLI_movelisttolist(ListBase *dst, ListBase *src) } /** + * moves the entire contents of \a src at the begining of \a dst. + */ +void BLI_movelisttolist_reverse(ListBase *dst, ListBase *src) +{ + if (src->first == NULL) return; + + if (dst->first == NULL) { + dst->first = src->first; + dst->last = src->last; + } + else { + ((Link *)src->last)->next = dst->first; + ((Link *)dst->first)->prev = src->last; + dst->first = src->first; + } + + src->first = src->last = NULL; +} + +/** * Prepends \a vlink (assumed to begin with a Link) onto listbase. */ void BLI_addhead(ListBase *listbase, void *vlink) @@ -578,6 +598,9 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset) Link *link = NULL; const char *id_iter; + if (id == NULL) + return NULL; + for (link = listbase->first; link; link = link->next) { id_iter = ((const char *)link) + offset; |