开发者

how to free memory when using TinyXML?

开发者 https://www.devze.com 2023-03-30 03:06 出处:网络
I am looking over leak memory. I am working with Valgrind and i have some errors like: Invalid read of size 1

I am looking over leak memory. I am working with Valgrind and i have some errors like:

Invalid read of size 1
==6643==    at 0x4026CC4: strlen (mc_replace_strmem.c:282)
==6643==    by 0x40D42DA: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
==6643==    by 0x804B8AB: main
==6643==  Address 0x441f895 is 13 bytes inside a block of size 45 free'd
==6643==    at 0x4025504: operator delete(void*) (vg_replace_malloc.c:387)
==6643==    by 0x40D1ACC: std::string::_Rep::_M_destroy(std::allocator<char> const&) 
==6643==    by 0x40D1B8B: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() 
==6643==    by 0x804CE6A: TiXmlNode::~TiXmlNode() 
==6643==    by 0x80B6241: TiXmlText::~TiXmlText() 
==6643==    by 0x804D0B0: TiXmlNode::Clear()
==6643==    by 0x804E13E: TiX开发者_如何转开发mlElement::ClearThis() 

The code is:

TiXmlHandle handle(&doc);


TiXmlElement* section,*pRoot,*pParam,*section1,*section2;

pRoot=doc.FirstChildElement("xml");


 pParam=pRoot->FirstChildElement("Data");

while (pParam)
{

section = pParam->FirstChildElement("Name");
    if (section)
   {

    const char* str= section->GetText();

    long long int v;
    sscanf(str, "%lld", &v);


    }

Appreciate. THX

0

精彩评论

暂无评论...
验证码 换一张
取 消