diff --git a/pvDataApp/factory/AbstractPVField.h b/pvDataApp/factory/AbstractPVField.h index 662d3a5..6631bad 100644 --- a/pvDataApp/factory/AbstractPVField.h +++ b/pvDataApp/factory/AbstractPVField.h @@ -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; igetField(); @@ -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()); } } diff --git a/pvDataApp/factory/BasePVStructure.h b/pvDataApp/factory/BasePVStructure.h index d205d4f..fd07712 100644 --- a/pvDataApp/factory/BasePVStructure.h +++ b/pvDataApp/factory/BasePVStructure.h @@ -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) diff --git a/pvDataApp/factory/FieldCreateFactory.cpp b/pvDataApp/factory/FieldCreateFactory.cpp index 13b69bb..6c81708 100644 --- a/pvDataApp/factory/FieldCreateFactory.cpp +++ b/pvDataApp/factory/FieldCreateFactory.cpp @@ -183,6 +183,7 @@ Structure::Structure (String fieldName, // inc reference counter fields[i]->incReferenceCount(); } + this->incReferenceCount(); } Structure::~Structure() { diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 7b5bd5c..a1b56c8 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -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); diff --git a/test/testIntrospect b/test/testIntrospect index e5aba72..41e60c8 100644 --- a/test/testIntrospect +++ b/test/testIntrospect @@ -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 diff --git a/test/testIntrospectDiff b/test/testIntrospectDiff index e69de29..9d85572 100644 --- a/test/testIntrospectDiff +++ b/test/testIntrospectDiff @@ -0,0 +1,4 @@ +82c82 +< field: totalConstruct 156 totalDestruct 43 totalReference 169 +--- +> field: totalConstruct 156 totalDestruct 63 totalReference 93 diff --git a/test/testLinkedListAux b/test/testLinkedListAux index 2feefcc..2ded144 100644 --- a/test/testLinkedListAux +++ b/test/testLinkedListAux @@ -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 diff --git a/test/testPVAuxInfo b/test/testPVAuxInfo index 0ea79ff..a4580a8 100644 --- a/test/testPVAuxInfo +++ b/test/testPVAuxInfo @@ -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 diff --git a/test/testPVAuxInfoDiff b/test/testPVAuxInfoDiff index e69de29..5538f12 100644 --- a/test/testPVAuxInfoDiff +++ b/test/testPVAuxInfoDiff @@ -0,0 +1,4 @@ +38c38 +< field: totalConstruct 111 totalDestruct 12 totalReference 126 +--- +> field: totalConstruct 111 totalDestruct 18 totalReference 93 diff --git a/test/testPVData b/test/testPVData index 8199210..296be02 100644 --- a/test/testPVData +++ b/test/testPVData @@ -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 diff --git a/test/testPVDataDiff b/test/testPVDataDiff index e69de29..045827d 100644 --- a/test/testPVDataDiff +++ b/test/testPVDataDiff @@ -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 diff --git a/test/testPVStructureArray b/test/testPVStructureArray index 3e016bb..606a864 100644 --- a/test/testPVStructureArray +++ b/test/testPVStructureArray @@ -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 diff --git a/test/testPVStructureArrayDiff b/test/testPVStructureArrayDiff index e69de29..c6a4c4b 100644 --- a/test/testPVStructureArrayDiff +++ b/test/testPVStructureArrayDiff @@ -0,0 +1,4 @@ +59c59 +< field: totalConstruct 153 totalDestruct 31 totalReference 185 +--- +> field: totalConstruct 153 totalDestruct 60 totalReference 93 diff --git a/test/testThreadAux b/test/testThreadAux index ef103fe..901c952 100644 --- a/test/testThreadAux +++ b/test/testThreadAux @@ -1 +1 @@ -time per call 38.080599 microseconds +time per call 41.194820 microseconds diff --git a/test/testTimeStampAux b/test/testTimeStampAux index 0ccd9f8..d599870 100644 --- a/test/testTimeStampAux +++ b/test/testTimeStampAux @@ -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 diff --git a/test/testTimerAux b/test/testTimerAux index b6a7606..2fb8c73 100644 --- a/test/testTimerAux +++ b/test/testTimerAux @@ -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 diff --git a/testApp/pv/testPVData.cpp b/testApp/pv/testPVData.cpp index f3dd870..5349b3b 100644 --- a/testApp/pv/testPVData.cpp +++ b/testApp/pv/testPVData.cpp @@ -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( + 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);