fix append problem
still may have memory leak problem
This commit is contained in:
@@ -185,7 +185,7 @@ void PVField::replacePVField(PVField * newPVField)
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
pvFields[index] = newPVField;
|
||||
parent->replaceStructure(parent);
|
||||
parent->replaceStructure(parent,length);
|
||||
}
|
||||
|
||||
void PVField::renameField(String newName)
|
||||
@@ -320,10 +320,9 @@ void PVField::computeOffset(PVField * pvField,int offset) {
|
||||
pvField->pImpl->nextFieldOffset = nextOffset;
|
||||
}
|
||||
|
||||
void PVField::replaceStructure(PVStructure *pvStructure)
|
||||
void PVField::replaceStructure(PVStructure *pvStructure,int length)
|
||||
{
|
||||
PVFieldPtrArray pvFields = pvStructure->getPVFields();
|
||||
int length = pvStructure->getStructure()->getNumberFields();
|
||||
FieldConstPtrArray newFields = new FieldConstPtr[length];
|
||||
for(int i=0; i<length; i++) {
|
||||
newFields[i] = pvFields[i]->getField();
|
||||
@@ -333,7 +332,7 @@ void PVField::replaceStructure(PVStructure *pvStructure)
|
||||
pImpl->field = newStructure;
|
||||
PVStructure *parent = pImpl->parent;
|
||||
if(parent!=0) {
|
||||
parent->replaceStructure(parent);
|
||||
parent->replaceStructure(parent,parent->getStructure()->getNumberFields());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace epics { namespace pvData {
|
||||
delete[] pImpl->pvFields;
|
||||
pImpl->pvFields = newPVFields;
|
||||
pImpl->numberFields = origLength + 1;
|
||||
PVField::replaceStructure(this);
|
||||
PVField::replaceStructure(this,pImpl->numberFields);
|
||||
}
|
||||
|
||||
void PVStructure::appendPVFields(int numberNewFields,PVFieldPtrArray pvFields)
|
||||
@@ -154,7 +154,7 @@ namespace epics { namespace pvData {
|
||||
delete[] pImpl->pvFields;
|
||||
pImpl->pvFields = newPVFields;
|
||||
pImpl->numberFields = numberFields;
|
||||
PVField::replaceStructure(this);
|
||||
PVField::replaceStructure(this,numberFields);
|
||||
}
|
||||
|
||||
void PVStructure::removePVField(String fieldName)
|
||||
@@ -178,7 +178,7 @@ namespace epics { namespace pvData {
|
||||
delete[] pImpl->pvFields;
|
||||
pImpl->pvFields = newPVFields;
|
||||
pImpl->numberFields = newLength;
|
||||
PVField::replaceStructure(this);
|
||||
PVField::replaceStructure(this,newLength);
|
||||
}
|
||||
|
||||
PVBoolean *PVStructure::getBooleanField(String fieldName)
|
||||
|
||||
@@ -183,6 +183,7 @@ Structure::Structure (String fieldName,
|
||||
// inc reference counter
|
||||
fields[i]->incReferenceCount();
|
||||
}
|
||||
this->incReferenceCount();
|
||||
}
|
||||
|
||||
Structure::~Structure() {
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
virtual bool operator!=(PVField &pv) = 0;
|
||||
protected:
|
||||
PVField(PVStructure *parent,FieldConstPtr field);
|
||||
void replaceStructure(PVStructure *pvStructure);
|
||||
void replaceStructure(PVStructure *pvStructure,int numberFields);
|
||||
private:
|
||||
class PVFieldPvt *pImpl;
|
||||
static void computeOffset(PVField *pvField);
|
||||
|
||||
@@ -79,5 +79,5 @@ structure value
|
||||
int nanoSeconds
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 156 totalDestruct 63 totalReference 93
|
||||
field: totalConstruct 156 totalDestruct 43 totalReference 169
|
||||
pvField: totalConstruct 55 totalDestruct 55
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
82c82
|
||||
< field: totalConstruct 156 totalDestruct 43 totalReference 169
|
||||
---
|
||||
> field: totalConstruct 156 totalDestruct 63 totalReference 93
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
|
||||
Time test
|
||||
diff 28.744510 milliSeconds
|
||||
time per iteration 28.744510 microseconds
|
||||
time per addTail/removeHead 0.014372 microseconds
|
||||
diff 27.074538 milliSeconds
|
||||
time per iteration 27.074538 microseconds
|
||||
time per addTail/removeHead 0.013537 microseconds
|
||||
|
||||
Time test locked
|
||||
diff 187.872582 milliSeconds
|
||||
time per iteration 187.872582 microseconds
|
||||
time per addTail/removeHead 0.093936 microseconds
|
||||
diff 173.292669 milliSeconds
|
||||
time per iteration 173.292669 microseconds
|
||||
time per addTail/removeHead 0.086646 microseconds
|
||||
|
||||
Time std::list test
|
||||
diff 682.009561 milliSeconds
|
||||
time per iteration 682.009561 microseconds
|
||||
time per addTail/removeHead 0.341005 microseconds
|
||||
diff 649.310063 milliSeconds
|
||||
time per iteration 649.310063 microseconds
|
||||
time per addTail/removeHead 0.324655 microseconds
|
||||
|
||||
Time std::list test locked
|
||||
diff 817.248344 milliSeconds
|
||||
time per iteration 817.248344 microseconds
|
||||
time per addTail/removeHead 0.408624 microseconds
|
||||
diff 799.799680 milliSeconds
|
||||
time per iteration 799.799680 microseconds
|
||||
time per addTail/removeHead 0.399900 microseconds
|
||||
|
||||
@@ -35,6 +35,6 @@ low offset 13 next 14 number 1
|
||||
high offset 14 next 15 number 1
|
||||
linkedListNode: totalConstruct 6 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 111 totalDestruct 18 totalReference 93
|
||||
field: totalConstruct 111 totalDestruct 12 totalReference 126
|
||||
pvField: totalConstruct 17 totalDestruct 17
|
||||
pvAuxInfo: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
38c38
|
||||
< field: totalConstruct 111 totalDestruct 12 totalReference 126
|
||||
---
|
||||
> field: totalConstruct 111 totalDestruct 18 totalReference 93
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
structure request
|
||||
string fieldList value,timeStamp
|
||||
|
||||
testScalar
|
||||
boolean boolean true
|
||||
@@ -283,5 +285,5 @@ structure string
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 388 totalDestruct 295 totalReference 93
|
||||
pvField: totalConstruct 279 totalDestruct 279
|
||||
field: totalConstruct 391 totalDestruct 202 totalReference 443
|
||||
pvField: totalConstruct 281 totalDestruct 281
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
1,2d0
|
||||
< structure request
|
||||
< string fieldList value,timeStamp
|
||||
288,289c286,287
|
||||
< field: totalConstruct 391 totalDestruct 202 totalReference 443
|
||||
< pvField: totalConstruct 281 totalDestruct 281
|
||||
---
|
||||
> field: totalConstruct 388 totalDestruct 295 totalReference 93
|
||||
> pvField: totalConstruct 279 totalDestruct 279
|
||||
|
||||
@@ -56,5 +56,5 @@ structure powerSupply
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 153 totalDestruct 60 totalReference 93
|
||||
field: totalConstruct 153 totalDestruct 31 totalReference 185
|
||||
pvField: totalConstruct 56 totalDestruct 56
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
59c59
|
||||
< field: totalConstruct 153 totalDestruct 31 totalReference 185
|
||||
---
|
||||
> field: totalConstruct 153 totalDestruct 60 totalReference 93
|
||||
|
||||
@@ -1 +1 @@
|
||||
time per call 38.080599 microseconds
|
||||
time per call 41.194820 microseconds
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
current 1293027467 787274811 milliSec 1293027467787
|
||||
2010.12.22 09:17:47 787274811 nanoSeconds isDst false
|
||||
current 1293395469 853440425 milliSec 1293395469853
|
||||
2010.12.26 15:31:09 853440425 nanoSeconds isDst false
|
||||
fromTime_t
|
||||
current 1293027467 0 milliSec 1293027467000
|
||||
2010.12.22 09:17:47 0 nanoSeconds isDst false
|
||||
current 1293395469 0 milliSec 1293395469000
|
||||
2010.12.26 15:31:09 0 nanoSeconds isDst false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
one requested 0.400000 diff 0.400192 seconds
|
||||
two requested 0.200000 diff 0.200170 seconds
|
||||
one requested 0.200000 diff 0.200340 seconds
|
||||
two requested 0.400000 diff 0.400313 seconds
|
||||
one requested 0.000000 diff 0.000046 seconds
|
||||
two requested 0.000000 diff 0.000068 seconds
|
||||
one requested 0.400000 diff 0.400393 seconds
|
||||
two requested 0.200000 diff 0.200411 seconds
|
||||
one requested 0.200000 diff 0.200244 seconds
|
||||
two requested 0.400000 diff 0.400291 seconds
|
||||
one requested 0.000000 diff 0.000131 seconds
|
||||
two requested 0.000000 diff 0.000155 seconds
|
||||
|
||||
@@ -34,6 +34,21 @@ static String alarmTimeStamp("alarm,timeStamp");
|
||||
static String alarmTimeStampValueAlarm("alarm,timeStamp,valueAlarm");
|
||||
static String allProperties("alarm,timeStamp,display,control,valueAlarm");
|
||||
|
||||
static void testAppend(FILE * fd)
|
||||
{
|
||||
FieldConstPtrArray fields = new FieldConstPtr[0];
|
||||
PVStructure *pvParent = pvDataCreate->createPVStructure(
|
||||
0,String("request"),0,fields);
|
||||
PVString* pvStringField = static_cast<PVString*>(
|
||||
pvDataCreate->createPVScalar(pvParent, "fieldList", pvString));
|
||||
pvStringField->put(String("value,timeStamp"));
|
||||
pvParent->appendPVField(pvStringField);
|
||||
builder.clear();
|
||||
pvParent->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
delete pvParent;
|
||||
}
|
||||
|
||||
static void testPVScalarCommon(FILE * fd,String fieldName,ScalarType stype)
|
||||
{
|
||||
PVScalar *pvScalar = standardPVField->scalar(0,fieldName,stype);
|
||||
@@ -264,6 +279,7 @@ int main(int argc,char *argv[])
|
||||
standardField = getStandardField();
|
||||
standardPVField = getStandardPVField();
|
||||
convert = getConvert();
|
||||
testAppend(fd);
|
||||
testPVScalar(fd);
|
||||
testScalarArray(fd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
|
||||
Reference in New Issue
Block a user