Ignore:
Timestamp:
06/04/10 14:55:53 (14 years ago)
Author:
hozdoba
Message:

Suppression de nombreuses fuites mémoires (200kbytes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/xmlio_xml_parser.hpp

    r95 r96  
    1818            { 
    1919               THashAttributes attributes; 
    20                 
     20                               
    2121               do {                 
    2222                 // Traitement de l'identifiant 
     
    3636                   
    3737               } while (_node.goToNextElement());                
    38             }     
     38            }  
     39             
     40            static void FreeMemory(void) 
     41            { 
     42               HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 
     43                
     44               for (HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 
     45               { 
     46                  string& id = (*it).first; 
     47                  StrHashMap<Context>& sc = (*it).second; 
     48                  // BUG AllListContext contient une StrHashMap<Context> liée à l'identifiant "" d'où la vérification ci-dessous. 
     49                  if (id.size()>0) delete sc[id]; 
     50               } 
     51            } 
    3952             
    4053            static bool CLASS_TEST(const string& file = string("/local/testsuite/iodef_test.xml"), ostream& log = std::clog) 
    4154            { 
    4255               ifstream istr( file.c_str() , ifstream::in ); 
    43                XMLNode node = XMLNode::CreateNode(istr); 
     56               XMLNode node("simulation"); 
     57               XMLNode::CreateNode(node, istr); 
    4458               XMLParser::Parse(node); 
    45                log << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 2 attendus."<< std::endl; 
     59               log << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 1 attendus."<< std::endl; 
    4660               log << "Nombre de FieldGroups listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 5 attendus."<< std::endl; 
    4761               log << "Description du champs votkeavt : " << Field::GetObject("votkeavt").description << " contre \"Vertical Eddy Diffusivity\" attendus."<< std::endl; 
    4862                
    4963               log << "Test  XMLParser ... ok !" << std::endl; 
     64                
     65               FreeMemory(); // Pour supprimer la mémoire liée à l'allocation dynamique. 
     66                
    5067               return (true); 
    5168            } 
Note: See TracChangeset for help on using the changeset viewer.