@@ -198,13 +198,29 @@ static CppcheckLibraryData::MemoryResource loadMemoryResource(QXmlStreamReader &
198198 if (type != QXmlStreamReader::StartElement)
199199 continue ;
200200 const QString elementName = xmlReader.name ().toString ();
201- if (elementName == " alloc" ) {
201+ if (elementName == " alloc" || elementName == " realloc " ) {
202202 CppcheckLibraryData::MemoryResource::Alloc alloc;
203+ alloc.isRealloc = (elementName == " realloc" );
203204 alloc.init = (xmlReader.attributes ().value (" init" ).toString () == " true" );
205+ if (xmlReader.attributes ().hasAttribute (" arg" )) {
206+ alloc.arg = xmlReader.attributes ().value (" arg" ).toInt ();
207+ }
208+ if (alloc.isRealloc && xmlReader.attributes ().hasAttribute (" realloc-arg" )) {
209+ alloc.reallocArg = xmlReader.attributes ().value (" realloc-arg" ).toInt ();
210+ }
211+ if (memoryresource.type == " memory" ) {
212+ alloc.bufferSize = xmlReader.attributes ().value (" buffer-size" ).toString ();
213+ }
204214 alloc.name = xmlReader.readElementText ();
205215 memoryresource.alloc .append (alloc);
206- } else if (elementName == " dealloc" )
207- memoryresource.dealloc .append (xmlReader.readElementText ());
216+ } else if (elementName == " dealloc" ) {
217+ CppcheckLibraryData::MemoryResource::Dealloc dealloc;
218+ if (xmlReader.attributes ().hasAttribute (" arg" )) {
219+ dealloc.arg = xmlReader.attributes ().value (" arg" ).toInt ();
220+ }
221+ dealloc.name = xmlReader.readElementText ();
222+ memoryresource.dealloc .append (dealloc);
223+ }
208224 else if (elementName == " use" )
209225 memoryresource.use .append (xmlReader.readElementText ());
210226 else
@@ -437,14 +453,34 @@ static void writeMemoryResource(QXmlStreamWriter &xmlWriter, const CppcheckLibra
437453{
438454 xmlWriter.writeStartElement (mr.type );
439455 foreach (const CppcheckLibraryData::MemoryResource::Alloc &alloc, mr.alloc ) {
456+ if (alloc.isRealloc ) {
457+ xmlWriter.writeStartElement (" realloc" );
458+ } else {
440459 xmlWriter.writeStartElement (" alloc" );
460+ }
441461 xmlWriter.writeAttribute (" init" , alloc.init ? " true" : " false" );
462+ if (alloc.arg != -1 ) {
463+ xmlWriter.writeAttribute (" arg" , QString (" %1" ).arg (alloc.arg ));
464+ }
465+ if (alloc.isRealloc && alloc.reallocArg != -1 ) {
466+ xmlWriter.writeAttribute (" realloc-arg" , QString (" %1" ).arg (alloc.reallocArg ));
467+ }
468+ if (mr.type == " memory" && !alloc.bufferSize .isEmpty ()) {
469+ xmlWriter.writeAttribute (" buffer-size" , alloc.bufferSize );
470+ }
442471 xmlWriter.writeCharacters (alloc.name );
443472 xmlWriter.writeEndElement ();
444473 }
445- foreach (const QString &dealloc, mr.dealloc ) {
446- xmlWriter.writeTextElement (" dealloc" , dealloc);
474+
475+ foreach (const CppcheckLibraryData::MemoryResource::Dealloc &dealloc, mr.dealloc ) {
476+ xmlWriter.writeStartElement (" dealloc" );
477+ if (dealloc.arg != -1 ) {
478+ xmlWriter.writeAttribute (" arg" , QString (" %1" ).arg (dealloc.arg ));
479+ }
480+ xmlWriter.writeCharacters (dealloc.name );
481+ xmlWriter.writeEndElement ();
447482 }
483+
448484 foreach (const QString &use, mr.use ) {
449485 xmlWriter.writeTextElement (" use" , use);
450486 }
0 commit comments