[rkward-cvs] SF.net SVN: rkward: [752] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Sep 20 15:24:03 UTC 2006


Revision: 752
          http://svn.sourceforge.net/rkward/?rev=752&view=rev
Author:   tfry
Date:     2006-09-20 08:23:57 -0700 (Wed, 20 Sep 2006)

Log Message:
-----------
Fix yet another storage allocation bug in RKVariable.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/core/rkvariable.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-09-20 14:39:36 UTC (rev 751)
+++ trunk/rkward/ChangeLog	2006-09-20 15:23:57 UTC (rev 752)
@@ -1,3 +1,4 @@
+- Yet another crash on more than 100 rows bug fixed
 - RKWard should now be fully UTF-8 aware. All characters are passed to and from R reliably
 
 --- Version 0.3.7 - Sep-17-2006

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2006-09-20 14:39:36 UTC (rev 751)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2006-09-20 15:23:57 UTC (rev 752)
@@ -383,12 +383,9 @@
 		return;
 	}
 
-	int target;
-	if (myData ()->allocated_length == 0) {
-		target = INITIAL_ALLOC;
-	} else {
-		target = myData ()->allocated_length * ALLOC_STEP;
-	}
+	int target = myData ()->allocated_length;
+	if (!target) target = INITIAL_ALLOC;
+	while (target < length) target = target * ALLOC_STEP;
 	RK_DO (qDebug ("resizing from %d to %d", myData ()->allocated_length, target), OBJECTS, DL_DEBUG);
 
 	QString **new_string_data = new QString*[target];
@@ -420,6 +417,7 @@
 		delete [] myData ()->cell_double_data;
 		myData ()->cell_double_data = 0;
 		for (int i = 0; i < myData ()->allocated_length; ++i) {
+#warning inefficient
 			deleteStringData (i);
 		}
 		delete [] myData ()->cell_string_data;
@@ -559,6 +557,7 @@
 	RK_ASSERT (to_row < getLength ());
 	
 	for (int row=from_row; row <= to_row; ++row) {
+#warning inefficient
 		deleteStringData (row);
 	}
 	
@@ -576,7 +575,6 @@
 	} else {
 		int i = 0;
 		for (int row=from_row; row <= to_row; ++row) {
-			deleteStringData (row);
 			if (isnan (data[i])) myData ()->cell_string_data[row] = na_char;
 			myData ()->cell_double_data[row] = data[i++];
 		}
@@ -612,6 +610,7 @@
 	if (getVarType () == String) {
 		int i=0;
 		for (int row=from_row; row <= to_row; ++row) {
+#warning inefficient
 			deleteStringData (row);
 			myData ()->cell_string_data[row] = new QString (data[i++]);
 		}
@@ -632,6 +631,7 @@
 	if ((to_row < 0)) to_row = myData ()->allocated_length - 1;
 		
 	for (int row=from_row; row <= to_row; ++row) {
+#warning inefficient
 		deleteStringData (row);
 		myData ()->cell_string_data[row] = unknown_char;
 	}
@@ -656,6 +656,7 @@
 /** see removeRow (), but removes a range of rows (i.e. cells). Since data only needs to be copied once, this is more efficient than several single calls to removeRow () */
 void RKVariable::removeRows (int from_row, int to_row) {
 	for (int row = from_row; row <= to_row; ++row) {
+#warning inefficient
 		deleteStringData (row);
 	}
 


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




More information about the rkward-tracker mailing list