after making google for long time also, i am unable to find reason/solution for crashing of xmlReaderForMemory,still with valid parameters.
i have created two parser function using libxml2,when i call individually they are working fine.But when i call one after another it is getting crashed on xmlReaderForMemory by giving error s follows:
First-chance exception at 0x7c918fea in nayak.exe: 0xC0000005: Access violation writing location 0x00000010. Unhandled exception at 0x7c918fea in nayak.exe: 0xC0000005: Access violation writing location 0x00000010.
now i am giving the code of the two functions:
FIRST FUNCTION:
char* CB_omniParser(char *omnistring){
char *parseResult,;
const char *fileName = omnistring;
char *temp,*texttemp,*result=0;
int i,len=0,error;
xmlTextReaderPtr reader;
len= strlen(omnistring);
if(len==0)
return 0;
reader = xmlReaderForMemory(fileName,len,"",NULL,0);
if(reader){
temp = (char *) GlobalAlloc(GPTR, sizeof(char)*len);
parseResult = (char *) GlobalAlloc(GPTR,sizeof(char)*len+1);
while(error=xmlTextReaderRead(reader)) {
if(error==-1){
return 0;
}
switch(xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT:
temp = (char *)xmlTextReaderConstName(reader);
strcat(parseResult,temp);
strcat(parseResult,"#");
xmlTextReaderMoveToElement(reader);
continue;
case XML_READER_TYPE_TEXT:
temp = (char *)xmlTextReaderConstValue(reader);
strcat(parseResult,temp);
strcat(parseResult,"|");
continue;
}
}
xmlFreeTextReader(reader);
xmlCleanupParser();
return parseResult;
}
else
return 0;
}
second function:
char* CB_xmlParserFromMemory(char *xmlstring){
char *xmlParseresult;
char *temp;
int i,len,,error;;
xmlTextReaderPtr reader1;
len= strlen(xmlstring);
if(len==0)
return 0;
reader1 = xmlReaderForMemory(xmlstring,len,NULL,NULL,0);
if(reader1){
temp = (char *) GlobalAlloc(GPTR, sizeof(char)*len);
while(error=xmlTextReaderRead(reader1)) {
if(error==-1){
return 0;
}
switch(xmlTextReaderNodeType(reader1)) {
case XML_READER_TYPE_ELEMENT:
temp = (char *)xmlTextReaderConstName(reader1);
strcat(xmlParseresult,"\"");
strcat(xmlParseresult,temp);
strcat(xmlParseresult,"\"");
strcat(xmlParseresult,":");
xmlTextReaderMoveToElement(reader1);
continue;
case XML_READER_TYPE_TEXT:
temp = (char *)xmlTextReaderConstValue(reader1);
strcat(xmlParseresult,"\"");
strcat(xmlParseresult,temp);
strcat(xmlParseresult,"\"");
strcat(xmlParseresult,",");
continue;
}
}
xmlCleanupParser();
xmlFreeTextReader(reader1);
GlobalFree(temp);
return xmlParseresult;
}
else
return 0;
}
both the functions are working individually fine.but if i call one function after another then both crashes at above given place...ith same error..plz help me.....