後崩潰了很長一段時間後,我也無法找到崩潰的xmlReaderForMemory,仍然有效的參數的原因/解決方案。xmlReaderForMemory在第二次調用
我創建的libxml使用,當我打電話逐個他們的工作fine.But當我陸續它是越來越給予誤差ε墜毀,機上xmlReaderForMemory叫一二解析器函數如下:
在第一次機會異常nayak.exe中0x7c918fea:0xC0000005:訪問衝突寫入位置0x00000010。 nayak.exe中的0x7c918fea未處理的異常:0xC0000005:訪問衝突寫入位置0x00000010。
現在我給的兩個函數的代碼:
第一個功能:
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; // on failure
}
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;//on success returns the parsed omni string
}
else
return 0; // on failure
}
二功能:
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; // on failure
}
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;//on success returns the parsed omni string
}
else
return 0; // on failure
}
兩個功能分別fine.but如果我的工作調用一個接一個的函數,然後在上述給定的地方崩潰......同樣的錯誤..plz幫助我.....
「但現在我不會給出理由,因爲你們也應該做一些工作......」 - wat – sehe