Project

Profile

Help

Revision 55b80284

Added by O'Neil Delpratt 5 months ago

Saxon/C added memory debugging and bug fixes

View differences:

src/main/c/Saxon.C.API/XsltExecutable.cpp
14 14
#include <typeinfo> //used for testing only
15 15
#endif
16 16

  
17
#ifdef MEM_DEBUG
18
#define new new(__FILE__, __LINE__)
19
#endif
17 20

  
18 21
XsltExecutable::XsltExecutable(jobject exObject, std::string curr) {
19 22

  
......
37 40
    selection = nullptr;
38 41
    selectionV = nullptr;
39 42
    saxonMessageListenerObj = nullptr;
40
    executableObject = exObject;
43
    executableObject = SaxonProcessor::sxn_environ->env->NewGlobalRef(exObject);
41 44
    cwdXE = curr;
42 45
}
43 46

  
......
235 238
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
236 239
#endif
237 240
                    delete value;
241
                    value = nullptr;
238 242
            }
239 243
        }
240 244
    }
......
945 949
                                                                                  "(Ljava/lang/String;Ljava/lang/String;)V");
946 950
        }
947 951
        if (!messageID) {
948
            std::cerr << "Error: "<<"SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
952
            std::cerr << "Error: SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
949 953
                      << std::endl;
950 954
            SaxonProcessor::sxn_environ->env->ExceptionClear();
951 955
        }
952 956

  
957
        jobject tempListenerObj;
953 958
        if (filename == nullptr) {
954
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
959
            tempListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
955 960
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF("-:on"));
956 961
            //setProperty("m", "on");
957 962
        } else {
958
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
963
            tempListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
959 964
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
960 965
        }
966
        if(tempListenerObj) {
967
            saxonMessageListenerObj = SaxonProcessor::sxn_environ->env->NewGlobalRef(tempListenerObj);
968
        } else {
969
            std::cerr << "Error: Failed to create SaxonCMessageListener" <<  std::endl;
970
        }
961 971
    } else {
962 972
        setProperty("m", "off");
963 973
    }

Also available in: Unified diff