在第二次通话xmlReaderForMemory崩溃 [英] xmlReaderForMemory crashes on 2nd time call

查看:449
本文介绍了在第二次通话xmlReaderForMemory崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做了很长一段时间也是谷歌之后,我无法与有效的参数找出原因/解决方案xmlReaderForMemory的崩溃,依然。

after making google for long time also, i am unable to find reason/solution for crashing of xmlReaderForMemory,still with valid parameters.

我一直在使用的libxml,当我单独叫他们正在fine.But当我陆续它过得去给错误S于xmlReaderForMemory坠毁叫一个跟随创建了两个解析器功能:

i have created two parser function using libxml,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:

在0x7c918fea在nayak.exe第一次机会异常:0000005:访问冲突写入位置0x00000010。
在0x7c918fea在nayak.exe未处理的异常:0000005:访问冲突写入位置0x00000010

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.

现在我给的两个函数的code:

now i am giving the code of the two functions:

第一个函数:

 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工作,如果我另一个则在上述地方都崩溃后调用一个函数......第i个相同error..plz帮我.....

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.....

推荐答案

我认为这是一个幸运的日子对我来说,因为我有机会来回答我的问题...

i think it's a lucky day for me as i am having the opportunity to answer my own question...

现在我很高兴,因为它是我的结束有工作完全没有任何问题,

now i am happy as it is working perfectly fine at my end with out any issue,

其实这个问题是内存(这并不是说,什么üř听单词的记忆发出后思考)。

Actually the issue was of memory(it's not that,what u r thinking after listening the word issue of memory).

问题正在提高,因为声明:

the issue was being raised because of the statement:

     xmlCleanupParser();

我已经使用而不是

as i have used instead of

   xmlInitParser ();

但现在我不会放弃的原因,是因为你们也应该做一些工作......

but now i will not give the reason,because you guys should also do some work...

但有一件事我会做的,即我给U中的网址这让我出去这....

but one thing i will do i.e i will give u the the URL which helped me to get out of this....

希望有至少可以得到的帮助摆脱这种.....

hope some at least get's help out of this.....

如果它满足您的需求,然后不要忘记了票这个答案,我会被别人当作第一选择.....谢谢Q .... LOVE UR code ... 。ENJY UR编码....

if it fulfills your requirement then don't forget to up-vote this answer as i will be taken as first choice by someone else.....THANK Q ....LOVE UR CODE.... ENJY UR CODING....

这篇关于在第二次通话xmlReaderForMemory崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆