[Bf-blender-cvs] [2ca67de9609] blender2.8: A new function to move list at the beginning of another list
Antonioya
noreply at git.blender.org
Sat Sep 29 16:55:09 CEST 2018
Commit: 2ca67de9609e297ed608469fd6a0d3a9dd9cad2f
Author: Antonioya
Date: Sat Sep 29 16:39:45 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2ca67de9609e297ed608469fd6a0d3a9dd9cad2f
A new function to move list at the beginning of another list
This is a change of the BLI_movelisttolist but in reverse order.
===================================================================
M source/blender/blenlib/BLI_listbase.h
M source/blender/blenlib/intern/listbase.c
===================================================================
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index c4ad5acfe4b..34e7a1fa212 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -82,6 +82,7 @@ void BLI_listbase_swaplinks(struct ListBase *listbase, void *vlinka, void *vlink
void BLI_listbases_swaplinks(struct ListBase *listbasea, struct ListBase *listbaseb, void *vlinka, void *vlinkb) ATTR_NONNULL(2, 3);
void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1, 2);
+void BLI_movelisttolist_reverse(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1, 2);
void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1, 2);
void BLI_listbase_reverse(struct ListBase *lb) ATTR_NONNULL(1);
void BLI_listbase_rotate_first(struct ListBase *lb, void *vlink) ATTR_NONNULL(1, 2);
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 80b8a8d041c..da187fbd19d 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -67,6 +67,26 @@ void BLI_movelisttolist(ListBase *dst, ListBase *src)
src->first = src->last = NULL;
}
+/**
+ * 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.
*/
More information about the Bf-blender-cvs
mailing list