[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] SF.net SVN: supercollider: [6886] trunk/Source/lang/LangPrimSource/ PyrArrayPrimitives.cpp



Revision: 6886
          http://svn.sourceforge.net/supercollider/?rev=6886&view=rev
Author:   joshpar
Date:     2008-01-07 08:55:50 -0800 (Mon, 07 Jan 2008)

Log Message:
-----------
fix wrapExtend clipExtend foldExtend

Modified Paths:
--------------
    trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp

Modified: trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp	2008-01-07 15:16:18 UTC (rev 6885)
+++ trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp	2008-01-07 16:55:50 UTC (rev 6886)
@@ -1651,18 +1651,22 @@
 		
 	obj1 = a->uo;
 	size = b->ui;
-	obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
-	obj2->size = size;
-	slots = obj2->slots;
-	// copy first part of list
-	memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
-	if (size > obj1->size) {
-		// copy second part
-		m = obj1->size;
-		for (i=0,j=m; j<size; ++i,++j) {
-			slots[j].ucopy = slots[i].ucopy;
+	if(obj1->size > 0) {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
+	    obj2->size = size;
+	    slots = obj2->slots;
+	    // copy first part of list
+	    memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
+	    if (size > obj1->size) {
+		    // copy second part
+		    m = obj1->size;
+		    for (i=0,j=m; j<size; ++i,++j) {
+			    slots[j].ucopy = slots[i].ucopy;
+		    }
 		}
-	}
+	    } else {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, true, true);
+	    }
 	a->uo = obj2;
 	return errNone;
 }
@@ -1679,18 +1683,22 @@
 		
 	obj1 = a->uo;
 	size = b->ui;
-	obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
-	obj2->size = size;
-	slots = obj2->slots;
-	// copy first part of list
-	memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
-	if (size > obj1->size) {
-		// copy second part
-		m = obj1->size;
-		for (i=0,j=m; j<size; ++i,++j) {
-			slots[j].ucopy = slots[sc_fold(j,0,m-1)].ucopy;
+	if(obj1->size > 0) {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
+	    obj2->size = size;
+	    slots = obj2->slots;
+	    // copy first part of list
+	    memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
+	    if (size > obj1->size) {
+		    // copy second part
+		    m = obj1->size;
+		    for (i=0,j=m; j<size; ++i,++j) {
+			    slots[j].ucopy = slots[sc_fold(j,0,m-1)].ucopy;
+		    }
 		}
-	}
+	    } else {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, true, true);
+	    }
 	a->uo = obj2;
 	return errNone;
 }
@@ -1707,19 +1715,23 @@
 		
 	obj1 = a->uo;
 	size = b->ui;
-	obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
-	obj2->size = size;
-	slots = obj2->slots;
-	// copy first part of list
-	memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
-	if (size > obj1->size) {
-		// copy second part
-		m = obj1->size;
-		last.ucopy = slots[m-1].ucopy;
-		for (i=0,j=m; j<size; ++i,++j) {
-			slots[j].ucopy = last.ucopy;
-		}
-	}
+	if(obj1->size > 0) {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, false, true);
+	    obj2->size = size;
+	    slots = obj2->slots;
+	    // copy first part of list
+	    memcpy(slots, obj1->slots, sc_min(size, obj1->size) * sizeof(PyrSlot));
+	    if (size > obj1->size) {
+		    // copy second part
+		    m = obj1->size;
+		    last.ucopy = slots[m-1].ucopy;
+		    for (i=0,j=m; j<size; ++i,++j) {
+			    slots[j].ucopy = last.ucopy;
+		    }
+		} 
+	    } else {
+	    obj2 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size, true, true);
+	    }
 	a->uo = obj2;
 	return errNone;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.