Menu

memory errors

Developer
Thomasisko
2005-07-02
2013-05-20
  • Thomasisko

    Thomasisko - 2005-07-02

    Hallo everybody. I use TinyXML Parser to work with a small XML database. I use very simple schema of XML file:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <diatoms>
    <circle/>
    <unknown/>
    </diatoms>
    </xml>

    Now I'd like to write some rows in both of elements circle and unknown. Every element contains name("file"), 25 double values and 1 string attribute. I use this source code to write a row:

    TiXmlElement* child = docHandle.FirstChild("diatoms").Element();
    TiXmlNode* shapeNode = child->FirstChild("circle");
        TiXmlElement *file = shapeNode->FirstChildElement("file");
    TiXmlElement tempElement("file");
    tempElement.SetAttribute("name", "aaa");
    tempElement.SetDoubleAttribute("ratio", fRatio);
           
    for(int i = 0; i<24; i++)
    {
      char strAttrName[20];
      //.. put some data in the strAttrName
      tempElement.SetDoubleAttribute(strAttrName,0.2);
    }

    shapeNode->InsertEndChild(tempElement);
    xml.SaveFile();

    I link TinyXML source files into my Borland C++ project. After writing about 50 rows into XML, it always fails with an error message referring to memory problems in method emtpy_it() from the file tinystr.h. The "possibly wrong" row is if(cstring) delete []cstring; I have to use the method SaveFile after each written row. Maybe that causes that error. If i comment the row xml.SaveFile(), no data will be written(that's clear), but I don't become the error message.

    Thanks for your advices

    Tomas

     
    • Andrew Walton

      Andrew Walton - 2005-07-10

      Well, I'm not too familiar with TinyXML (just recently started developing with it), but you seem to have a language conflict;

      You say you are using Borland C++ (which I have never worked with) but you are using the C-style access. Any reason for this? Perhaps you can switch to the STL version?

      I would try enabling it in the project, and rebuilding it to see if the error still presents itself.

      Hope this helps.
      Andrew

       

Log in to post a comment.

MongoDB Logo MongoDB