MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / loadMemoryResource

Function loadMemoryResource

gui/cppchecklibrarydata.cpp:257–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static CppcheckLibraryData::MemoryResource loadMemoryResource(QXmlStreamReader &xmlReader)
258{
259 CppcheckLibraryData::MemoryResource memoryresource;
260 memoryresource.type = xmlReader.name().toString();
261 QXmlStreamReader::TokenType type;
262 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
263 xmlReader.name().toString() != memoryresource.type) {
264 if (type != QXmlStreamReader::StartElement)
265 continue;
266 const QString elementName = xmlReader.name().toString();
267 if (elementName == "alloc" || elementName == "realloc") {
268 CppcheckLibraryData::MemoryResource::Alloc alloc;
269 alloc.isRealloc = (elementName == "realloc");
270 alloc.noFail = (xmlReader.attributes().value("no-fail").toString() == "true");
271 alloc.init = (xmlReader.attributes().value("init").toString() == "true");
272 if (xmlReader.attributes().hasAttribute("arg")) {
273 alloc.arg = xmlReader.attributes().value("arg").toInt();
274 }
275 if (alloc.isRealloc && xmlReader.attributes().hasAttribute("realloc-arg")) {
276 alloc.reallocArg = xmlReader.attributes().value("realloc-arg").toInt();
277 }
278 if (memoryresource.type == "memory") {
279 alloc.bufferSize = xmlReader.attributes().value("buffer-size").toString();
280 }
281 alloc.name = xmlReader.readElementText();
282 memoryresource.alloc.append(alloc);
283 } else if (elementName == "dealloc") {
284 CppcheckLibraryData::MemoryResource::Dealloc dealloc;
285 if (xmlReader.attributes().hasAttribute("arg")) {
286 dealloc.arg = xmlReader.attributes().value("arg").toInt();
287 }
288 dealloc.name = xmlReader.readElementText();
289 memoryresource.dealloc.append(dealloc);
290 } else if (elementName == "use")
291 memoryresource.use.append(xmlReader.readElementText());
292 else
293 unhandledElement(xmlReader);
294 }
295 return memoryresource;
296}
297
298static CppcheckLibraryData::PodType loadPodType(const QXmlStreamReader &xmlReader)
299{

Callers 1

openMethod · 0.85

Calls 4

unhandledElementFunction · 0.85
toStringMethod · 0.45
nameMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected