[rkward-cvs] rkward/rkward/core rkvariable.cpp,1.33,1.34
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Thu Jun 22 00:12:19 UTC 2006
- Previous message: [rkward-cvs] rkward/rkward/rbackend rthread.cpp,1.38,1.39
- Next message: [rkward-cvs] rkward/rkward/settings rksettings.cpp, 1.9, 1.10 rksettings.h, 1.6, 1.7 rksettingsmoduler.cpp, 1.13, 1.14 rksettingsmoduler.h, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/rkward/rkward/rkward/core
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8414/rkward/core
Modified Files:
rkvariable.cpp
Log Message:
Fix data re-allocation in RKVariable
Index: rkvariable.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rkvariable.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** rkvariable.cpp 19 Jun 2006 20:04:30 -0000 1.33
--- rkvariable.cpp 22 Jun 2006 00:12:17 -0000 1.34
***************
*** 193,197 ****
////////////////////// BEGIN: data-handling //////////////////////////////
! #define ALLOC_STEP 100
#define RECHECK_VALID { if ((!myData ()->invalid_count) && (!myData ()->previously_valid)) restoreStorageInBackend (); }
--- 193,198 ----
////////////////////// BEGIN: data-handling //////////////////////////////
! #define ALLOC_STEP 2
! #define INITIAL_ALLOC 100
#define RECHECK_VALID { if ((!myData ()->invalid_count) && (!myData ()->previously_valid)) restoreStorageInBackend (); }
***************
*** 377,387 ****
if (length <= 0) length = 1;
! if (length <= myData ()->allocated_length) {
dimension[0] = length;
return;
}
!
! int target = length + ALLOC_STEP - (length % ALLOC_STEP);
!
char **new_string_data = new char*[target];
double *new_double_data = new double[target];
--- 378,394 ----
if (length <= 0) length = 1;
! if (length < (myData ()->allocated_length - 1)) {
dimension[0] = length;
return;
}
!
! int target;
! if (myData ()->allocated_length == 0) {
! target = INITIAL_ALLOC;
! } else {
! target = myData ()->allocated_length * ALLOC_STEP;
! }
! qDebug ("resizing from %d to %d", myData ()->allocated_length, target);
!
char **new_string_data = new char*[target];
double *new_double_data = new double[target];
***************
*** 691,702 ****
void RKVariable::insertRows (int row, int count) {
! for (int i=getLength (); i <= row+count; ++i) {
myData ()->cell_string_data[i] = RKGlobals::empty_char;
myData ()->cell_double_data[i] = 0;
}
! extendToLength (getLength () + count);
!
! qmemmove (&(myData ()->cell_string_data[row+count]), &(myData ()->cell_string_data[row]), (myData ()->allocated_length - (row + count) - 1) * sizeof (char*));
! qmemmove (&(myData ()->cell_double_data[row+count]), &(myData ()->cell_double_data[row]), (myData ()->allocated_length - (row + count) - 1) * sizeof (double));
for (int i=row+count-1; i >= row; --i) {
--- 698,716 ----
void RKVariable::insertRows (int row, int count) {
! int old_len = getLength ();
! extendToLength (getLength () + count);
!
! for (int i=old_len; i <= row+count; ++i) {
myData ()->cell_string_data[i] = RKGlobals::empty_char;
myData ()->cell_double_data[i] = 0;
}
!
! if (row >= getLength () && (count == 1)) { // important special case
! myData ()->cell_string_data[row+count] = myData ()->cell_string_data[row];
! myData ()->cell_double_data[row+count] = myData ()->cell_double_data[row];
! } else {
! qmemmove (&(myData ()->cell_string_data[row+count]), &(myData ()->cell_string_data[row]), (myData ()->allocated_length - (row + count) - 1) * sizeof (char*));
! qmemmove (&(myData ()->cell_double_data[row+count]), &(myData ()->cell_double_data[row]), (myData ()->allocated_length - (row + count) - 1) * sizeof (double));
! }
for (int i=row+count-1; i >= row; --i) {
- Previous message: [rkward-cvs] rkward/rkward/rbackend rthread.cpp,1.38,1.39
- Next message: [rkward-cvs] rkward/rkward/settings rksettings.cpp, 1.9, 1.10 rksettings.h, 1.6, 1.7 rksettingsmoduler.cpp, 1.13, 1.14 rksettingsmoduler.h, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the rkward-tracker
mailing list