[Kst] kdeextragear-2/kst/kst/datasources/cdf
George Staikos
staikos at kde.org
Thu Jul 29 03:26:32 CEST 2004
CVS commit by staikos:
fix some memory leaks, add index, make sure that index is compared .lower()
M +12 -9 cdf.cpp 1.3
--- kdeextragear-2/kst/kst/datasources/cdf/cdf.cpp #1.2:1.3
@@ -58,12 +58,9 @@ int CdfSource::readField(double *v, cons
char varName[CDF_VAR_NAME_LEN+1];
bool isZvar = true; /* Should be the case for recent cdf files */
- void *binary;
// Allocate an arbitrary (large) size
- binary = malloc(sizeof(long double));
-
kdDebug() << "Entering CdfSource::readField with params: " << field << ", from " << s << " for " << n << " values" << endl;
// Handle the special case where we query INDEX
- if (field == "INDEX") {
+ if (field.lower() == "index") {
for (i = 0; i < n; i++) {
v[i] = double(s + i);
@@ -78,9 +75,12 @@ int CdfSource::readField(double *v, cons
return -1;
}
+
+ QString ftmp = field;
+ ftmp.truncate(CDF_VAR_NAME_LEN);
// Variable selection
- strcpy(varName, field.latin1());
+ strcpy(varName, ftmp.latin1());
status = CDFlib(SELECT_, zVAR_NAME_, varName, GET_, zVAR_DATATYPE_, &dataType, NULL_);
if (status < CDF_OK) { // if not zVar, try rVar
- kdDebug() << field << ": " << " not a zVAR" << endl;
+ kdDebug() << ftmp << ": " << " not a zVAR" << endl;
isZvar = false;
status = CDFlib(SELECT_, rVAR_NAME_, varName, GET_, rVAR_DATATYPE_, &dataType, NULL_);
@@ -88,5 +88,5 @@ int CdfSource::readField(double *v, cons
// I suppose the returned int is the number of values read, <0 when there is a problem
if (status < CDF_OK) {
- kdDebug() << field << ": " << " not a rVAR either -> exiting" << endl;
+ kdDebug() << ftmp << ": " << " not a rVAR either -> exiting" << endl;
return -1;
}
@@ -101,4 +101,6 @@ int CdfSource::readField(double *v, cons
}
+ void *binary = malloc(sizeof(long double));
+
kdDebug() << "Starting to read " << n << " value(s)..." << endl;
for (i = s; i < s+n && i < maxRec; i++) {
@@ -107,4 +109,5 @@ int CdfSource::readField(double *v, cons
GET_, BOO(isZvar, zVAR_DATA_, rVAR_DATA_), binary,
NULL_);
+ kdDebug() << "v[" << i-s << "]" << endl;
switch (dataType) {
case CDF_INT2:
@@ -206,4 +209,6 @@ QStringList CdfSource::fieldList() const
CDFid id;
+ rc += "INDEX";
+
CDFstatus status = CDFopen(_filename.latin1(), &id);
if (status < CDF_OK) {
@@ -212,6 +217,4 @@ QStringList CdfSource::fieldList() const
}
- // rc += "INDEX"; seems to be added automatically ?
-
status = CDFlib(SELECT_, CDF_READONLY_MODE_, READONLYon,
GET_, CDF_NUMrVARS_, &numRvars,
More information about the Kst
mailing list