From a13f2fe66f4599e2828e6cf752d1a34dc37c0791 Mon Sep 17 00:00:00 2001 From: zilio nicolas Date: Fri, 4 Sep 2015 14:03:48 +0200 Subject: added cleanup --- pcilib/xml.c | 18 ++++++++++-------- pcilib/xml.h | 7 +++++++ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'pcilib') diff --git a/pcilib/xml.c b/pcilib/xml.c index 55cdf11..257b503 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -244,7 +244,6 @@ pcilib_xml_initialize_banks(pcilib_t* pci,xmlDocPtr doc){ xmlNodeSetPtr nodesetadress=NULL; xmlNodePtr mynode; - pcilib_register_bank_description_t* banks; xmlXPathContextPtr context; int i; @@ -253,21 +252,20 @@ pcilib_xml_initialize_banks(pcilib_t* pci,xmlDocPtr doc){ /** we get the bank nodes using xpath expression*/ nodesetadress=pcilib_xml_getsetproperty(context,BANKS_PATH)->nodesetval; - if(nodesetadress->nodeNr>0) banks=calloc((nodesetadress->nodeNr),sizeof(pcilib_register_bank_description_t)); - else return; + if(nodesetadress->nodeNr==0) return; pci->banks_xml_nodes=calloc(nodesetadress->nodeNr,sizeof(xmlNodePtr)); - if(!(pci->banks_xml_nodes)) pcilib_warning("can't create bank xml nodes for pcilib_t struct"); + if(!(pci->banks_xml_nodes)) pcilib_error("can't create bank xml nodes for pcilib_t struct"); - /** for each of the bank nodes, we create the associated structure*/ + /** for each of the bank nodes, we create the associated structure, and push it in the pcilib environnement*/ for(i=0;inodeNr;i++){ mynode=nodesetadress->nodeTab[i]; pcilib_xml_create_bank(&mybank,mynode,doc); - banks[i]=mybank; + pcilib_add_register_banks(pci,1,&mybank); pci->banks_xml_nodes[i]=mynode; } - /** we push our banks structures in the pcilib environnement*/ - pcilib_add_register_banks(pci,nodesetadress->nodeNr,banks); + + } /* @@ -567,6 +565,10 @@ int pcilib_init_xml(pcilib_t* ctx){ free(line); free(line_xsd); free(docs); + + xmlCleanupParser(); + xmlMemoryDump(); + return 0; } diff --git a/pcilib/xml.h b/pcilib/xml.h index 1ef8ee5..ef08d10 100644 --- a/pcilib/xml.h +++ b/pcilib/xml.h @@ -12,10 +12,17 @@ #ifndef _XML_ #define _XML_ +/*#include +#include +#include +#include +*/ #include "pcilib.h" #define REGISTERS_PATH ((xmlChar*)"/model/banks/bank/registers/register") /**