[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12457] branches/pynodes/source/blender: * merge trunk r12451:r12455

Nathan Letwory jesterking at letwory.net
Fri Nov 2 16:16:20 CET 2007


Revision: 12457
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12457
Author:   jesterking
Date:     2007-11-02 16:16:20 +0100 (Fri, 02 Nov 2007)

Log Message:
-----------
* merge trunk r12451:r12455

Modified Paths:
--------------
    branches/pynodes/source/blender/blenlib/BLI_blenlib.h
    branches/pynodes/source/blender/blenlib/intern/util.c
    branches/pynodes/source/blender/src/editipo.c

Modified: branches/pynodes/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- branches/pynodes/source/blender/blenlib/BLI_blenlib.h	2007-11-02 15:13:31 UTC (rev 12456)
+++ branches/pynodes/source/blender/blenlib/BLI_blenlib.h	2007-11-02 15:16:20 UTC (rev 12457)
@@ -112,6 +112,8 @@
 void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic);
 void BLI_addhead(struct ListBase *listbase, void *vlink);
 void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink);
+void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink);
+void BLI_sortlist(struct ListBase *listbase, int (*cmp)(void *, void *));
 void BLI_freelist(struct ListBase *listbase);
 int BLI_countlist(struct ListBase *listbase);
 void BLI_freelinkN(ListBase *listbase, void *vlink);

Modified: branches/pynodes/source/blender/blenlib/intern/util.c
===================================================================
--- branches/pynodes/source/blender/blenlib/intern/util.c	2007-11-02 15:13:31 UTC (rev 12456)
+++ branches/pynodes/source/blender/blenlib/intern/util.c	2007-11-02 15:16:20 UTC (rev 12457)
@@ -312,6 +312,76 @@
 	newlink->prev= prevlink;
 }
 
+/* This uses insertion sort, so NOT ok for large list */
+void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
+{
+	Link *current = NULL;
+	Link *previous = NULL;
+	Link *next = NULL;
+	
+	if (cmp == NULL) return;
+	if (listbase == NULL) return;
+
+	if (listbase->first != listbase->last)
+	{
+		for( previous = listbase->first, current = previous->next; current; previous = current, current = next )
+		{
+			next = current->next;
+			
+			BLI_remlink(listbase, current);
+			
+			while(previous && cmp(previous, current) == 1)
+			{
+				previous = previous->prev;
+			}
+			
+			if (previous == NULL)
+			{
+				BLI_addhead(listbase, current);
+			}
+			else
+			{
+				BLI_insertlinkafter(listbase, previous, current);
+			}
+		}
+	}
+}
+
+void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink)
+{
+	Link *prevlink= vprevlink;
+	Link *newlink= vnewlink;
+
+	/* newlink before nextlink */
+	if (newlink == NULL) return;
+	if (listbase == NULL) return;
+
+	/* empty list */
+	if (listbase->first == NULL) { 
+		listbase->first= newlink;
+		listbase->last= newlink;
+		return;
+	}
+	
+	/* insert at head of list */
+	if (prevlink == NULL) {	
+		newlink->prev = NULL;
+		newlink->next = listbase->first;
+		((Link *)listbase->first)->prev = newlink;
+		listbase->first = newlink;
+		return;
+	}
+
+	/* at end of list */
+	if (listbase->last == prevlink) 
+		listbase->last = newlink;
+
+	newlink->next = prevlink->next;
+	newlink->prev = prevlink;
+	prevlink->next = newlink;
+	if (newlink->next) newlink->next->prev = newlink;
+}
+
 void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
 {
 	Link *nextlink= vnextlink;

Modified: branches/pynodes/source/blender/src/editipo.c
===================================================================
--- branches/pynodes/source/blender/src/editipo.c	2007-11-02 15:13:31 UTC (rev 12456)
+++ branches/pynodes/source/blender/src/editipo.c	2007-11-02 15:16:20 UTC (rev 12457)
@@ -5023,9 +5023,9 @@
 	
 	/* dynamically allocate an array of chars to mark whether an TransData's 
 	 * pointers have been fixed already, so that we don't override ones that are
-	 * already done
+	 * already done (assumes sizeof(char)==1)
  	 */
-	adjusted= MEM_callocN(sizeof(char), "beztmap_adjusted_map");
+	adjusted= MEM_callocN(t->total, "beztmap_adjusted_map");
 	
 	/* for each beztmap item, find if it is used anywhere */
 	bezm= bezms;





More information about the Bf-blender-cvs mailing list