Project

Profile

Help

Revision 146cfacb

Added by O'Neil Delpratt 5 months ago

Saxon/C memory management patches

View differences:

src/main/c/Saxon.C.API/XPathProcessor.cpp
4 4
#include "XdmNode.h"
5 5
#include "XdmAtomicValue.h"
6 6
#include "XdmFunctionItem.h"
7
#include "XdmMap.h"
8
#include "XdmArray.h"
7 9

  
8 10
XPathProcessor::XPathProcessor() {
9 11
	SaxonProcessor *p = new SaxonProcessor(false);
......
101 103
		jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
102 104
		jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
103 105
		jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
106
        jclass mapClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmMap");
107
        jclass arrayClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmArray");
104 108

  
105 109
		XdmValue * value = new XdmValue();
106 110
		XdmItem * xdmItem = nullptr;
107 111
		for (int p=0; p < sizex; ++p) 
108 112
		{
109 113
			jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
110
			//value->addUnderlyingValue(resulti);
111 114

  
112 115
			if(SaxonProcessor::sxn_environ->env->IsInstanceOf(resulti, atomicValueClass)           == JNI_TRUE) {
113 116
				xdmItem = new XdmAtomicValue(resulti);
......
117 120

  
118 121
			} else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(resulti, functionItemClass)           == JNI_TRUE) {
119 122
				xdmItem =  new XdmFunctionItem(resulti);
120
			}
121
			if(sizex == 1) {
122
				value->decrementRefCount();
123
			} else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(resulti, mapClass)           == JNI_TRUE) {
124
                xdmItem =  new XdmMap(resulti);
125
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(resulti, arrayClass)           == JNI_TRUE) {
126
                xdmItem =  new XdmArray(resulti);
127
            }
128
            if(sizex == 1) {
123 129
				delete value;
124 130
				SaxonProcessor::sxn_environ->env->DeleteLocalRef(results);
125 131
				return xdmItem;		
......
380 386
            it = parameters.find(skey);
381 387
            if (it != parameters.end()) {
382 388
                XdmValue * valuei = it->second;
383
                valuei->decrementRefCount();
384
                if(valuei != nullptr && valuei->getRefCount() < 1){
385
                    delete value;
389
                if(valuei != nullptr) {
390
                    valuei->decrementRefCount();
391
                    if (valuei->getRefCount() < 1) {
392
                        delete value;
393
                    }
394
                    parameters.erase(skey);
395
                    parameters[skey] = value;
386 396
                }
387
                parameters.erase(skey);
388
                parameters[skey] = value;
389 397
            }
390 398
		}
391 399
	}
......
413 421
}
414 422

  
415 423
void XPathProcessor::clearParameters(bool delVal) {
416
	if(delVal){
417
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
418
			XdmValue * value = itr->second;
419
			value->decrementRefCount();
424
	if(delVal) {
425
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
426
            XdmValue *value = itr->second;
427
            if (value != nullptr) {
428
                value->decrementRefCount();
420 429
#ifdef DEBUG
421
			std::cerr<<"XPathProc.clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
430
                std::cerr<<"XPathProc.clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
422 431
#endif
423
			if(value != nullptr && value->getRefCount() < 1){
424
	        		delete value;
425
			}
426
        	}
427
		parameters.clear();
428
	}
432
                if (value->getRefCount() < 1) {
433
                    delete value;
434
                }
435
            }
436
        }
437
    }
438
	parameters.clear();
439

  
429 440
}
430 441

  
431 442
void XPathProcessor::clearProperties() {
src/main/c/Saxon.C.API/XQueryProcessor.cpp
130 130
            it = parameters.find(skey);
131 131
            if (it != parameters.end()) {
132 132
                XdmValue * valuei = it->second;
133
                valuei->decrementRefCount();
134
                if(valuei != nullptr && valuei->getRefCount() < 1){
135
                    delete value;
133
                if(valuei != nullptr) {
134
                    valuei->decrementRefCount();
135
                    if (valuei->getRefCount() < 1) {
136
                        delete value;
137
                    }
138
                    parameters.erase(skey);
139
                    parameters[skey] = value;
136 140
                }
137
                parameters.erase(skey);
138
                parameters[skey] = value;
139 141
            }
140 142
		}
141 143
	} 
......
185 187

  
186 188
    void XQueryProcessor::clearParameters(bool delVal){
187 189
	if(delVal){
188
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
189
			XdmValue * value = itr->second;
190
			value->decrementRefCount();
190
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
191
                XdmValue *value = itr->second;
192
                if (value != nullptr) {
193
                    value->decrementRefCount();
191 194
#ifdef DEBUG
192
			std::cerr<<"XQueryProc.clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
195
                    std::cerr<<"XQueryProc.clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
193 196
#endif
194
			if(value != nullptr && value->getRefCount() < 1){
195
	        		delete value;
196
			}
197
        	}
197
                    if (value->getRefCount() < 1) {
198
                        delete value;
199
                    }
200
                }
201
            }
198 202
		
199 203
	} else {
200 204

  
201 205
		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
202 206
			XdmValue * value = itr->second;
203
			value->decrementRefCount();
204

  
205
        	}
207
			if(value != nullptr) {
208
                value->decrementRefCount();
209
            }
210
		}
206 211
	}
207 212

  
208 213
	parameters.clear();
src/main/c/Saxon.C.API/XdmAtomicValue.cpp
21 21
    }
22 22

  
23 23
    XdmAtomicValue::~XdmAtomicValue(){
24
        std::cerr<<"XdmAtomicValue destructor called"<<std::endl;
24
        std::cerr<<"XdmAtomicValue destructor called ref="<<getRefCount()<<std::endl;
25 25
        if(!valType.empty()) {
26 26
            valType.clear();
27 27
        }
src/main/c/Saxon.C.API/XdmItem.cpp
36 36
}
37 37

  
38 38

  
39

  
40

  
41
   XdmItem * XdmItem::getHead(){ return this;}
39
XdmItem * XdmItem::getHead(){ return this;}
42 40

  
43 41
  XdmItem * XdmItem::itemAt(int n){
44 42
	if (n < 0 || n >= size()) {
......
95 93
	}
96 94

  
97 95
XdmItem::~XdmItem() {
98
    decrementRefCount();
96
    //decrementRefCount();
99 97
    std::cerr<<std::endl<<"XdmItem destructor called, refCount"<<getRefCount()<<std::endl;
100
    std::cout << std::endl << "cpp0-1" << std::endl;
98

  
101 99
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
102 100

  
103
    if(getRefCount()<1){
104
        if(value !=nullptr && SaxonProcessor::jvmCreatedCPP>0) {
105
            SaxonProcessor::sxn_environ->env->DeleteGlobalRef(value);
106
        }
107
        std::cout << std::endl << "cpp0-1" << std::endl;
108
        SaxonProcessor::sxn_environ->env->ExceptionDescribe();
109
        if(stringValue.empty()) {
110
            stringValue.clear();
111
        }
101
    if(value !=nullptr && SaxonProcessor::jvmCreatedCPP>0) {
102
        std::cout << std::endl << "cpp0-1: DeleteGlobalRef" << std::endl;
103
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(value);
104
    }
105
    std::cout << std::endl << "cpp0-1" << std::endl;
106
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
107
    if(stringValue.empty()) {
108
        stringValue.clear();
112 109
    }
113 110
}
114 111

  
src/main/c/Saxon.C.API/XdmValue.cpp
126 126

  
127 127

  
128 128
XdmValue::~XdmValue() {
129
	bool safeToClear = false;
129
	//bool safeToClear = false;
130 130
	std::cout<<"xdmValue destructor size= "<<values.size()<<" ref="<<getRefCount()<<std::endl;
131
    if(getRefCount()<1){
132
        std::cout<<"xdmValue destructor refCount="<<getRefCount()<<" values.size="<<values.size()<<std::endl;
131
    //if(getRefCount()<1){
132
    std::cout<<"xdmValue destructor refCount="<<getRefCount()<<" values.size="<<values.size()<<std::endl;
133 133
	//proc->env->ReleaseObject
134
	for (size_t i = 0; i < values.size(); i++) {
135
	    values[i]->decrementRefCount();
136
        std::cout<<"xdmItem (XdmValue destructor) refCount="<<values[i]->getRefCount()<<std::endl;
137
		if (values[i] != nullptr && values[i]->getRefCount() < 1) {
138
			delete values[i];
139
			safeToClear = true;
140
		} else {
141
			safeToClear = false;
142
		}
143
	}
144
	if(safeToClear) {
145
		values.clear();
146
	}
134
	if(values.size() > 0) {
135
        for (size_t i = 0; i < values.size(); i++) {
136
            values[i]->decrementRefCount();
137
            std::cout << "xdmItem (XdmValue destructor) refCount=" << values[i]->getRefCount() << std::endl;
138
            if (values[i] != nullptr && values[i]->getRefCount() < 1) {
139
                delete values[i];
140
            }
141
        }
142
        values.clear();
143
    }
147 144
	if (valueType != nullptr) { delete valueType; }
148 145
	if (jValues) {
149
        std::cout<<"xdmValue jni"<<getRefCount()<<std::endl;
146
        std::cout<<"xdmValue (jValues) jni"<<getRefCount()<<std::endl;
150 147
		SaxonProcessor::sxn_environ->env->DeleteLocalRef(jValues);
151 148
	}
152 149
	xdmSize = 0;
153 150

  
154
    }
151
    //}
155 152

  
156 153
    if(!toStringValue.empty()) {
157 154
        toStringValue.clear();
src/main/c/Saxon.C.API/Xslt30Processor.cpp
107 107
            it = parameters.find(skey);
108 108
            if (it != parameters.end()) {
109 109
                XdmValue * valuei = it->second;
110
                valuei->decrementRefCount();
111
                if(valuei != nullptr && valuei->getRefCount() < 1){
112
                    delete value;
110
                if(valuei != nullptr) {
111
                    valuei->decrementRefCount();
112
                    if (valuei->getRefCount() < 1) {
113
                        delete value;
114
                    }
115
                    parameters.erase(skey);
116
                    parameters[skey] = value;
117
                    value->incrementRefCount();
113 118
                }
114
                parameters.erase(skey);
115
                parameters[skey] = value;
116 119
            }
117 120
		}
118 121
	 }
......
136 139

  
137 140

  
138 141
void Xslt30Processor::clearParameters(bool delValues) {
139

  
142
    std::cout<<"clearParameter" <<std::endl;
140 143
	if(delValues){
141
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
142
			
143
			XdmValue * value = itr->second;
144
			value->decrementRefCount();
144
        for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
145
            XdmValue * value = itr->second;
146
            std::cout<<"clearParameter cp0" <<"ob ref="<<(value)<<std::endl;
147
            if(value != nullptr) {
148
                std::cout<<"clearParameter cp0-1" <<std::endl;
149
                value->decrementRefCount();
145 150
#ifdef DEBUG
146
			std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
151
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
147 152
#endif
148
			if(value != nullptr && value->getRefCount() < 1){
149
	        		delete value;
150
			}
151
        	}
153
                if (value->getRefCount() < 1) {
154
                    delete value;
155
                }
156
            }
157
            std::cout<<"clearParameter cp0-2" <<std::endl;
158
        }
152 159

  
153 160
	} else {
154
for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
155
		
161
        std::cout<<"clearParameter cp1-0" <<std::endl;
162
        for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
163

  
156 164
			XdmValue * value = itr->second;
157
			value->decrementRefCount();
165
            std::cout<<"clearParameter cp1" <<"ob ref="<<(value)<<std::endl;
166

  
167
            if(value == NULL) {
168
                std::cout<<"clearParameter cp1-0 after itr NULL found!!!!!" <<std::endl;
169
            }
170
			if(value != nullptr) {
171
                std::cout<<"clearParameter cp1-1" <<std::endl;
172
                value->decrementRefCount();
173
            }
158 174
		
159 175
        	}
160 176

  
161 177
	}
178
    std::cout<<"clearParameter cp1" <<std::endl;
162 179
	parameters.clear();
180
    std::cout<<"clearParameter cp2" <<std::endl;
163 181

  
164 182
	
165 183
}
src/main/c/Saxon.C.API/XsltExecutable.cpp
81 81

  
82 82
        XdmValue *valuei = paramIter->second;
83 83
        if (valuei == nullptr) {
84
            std::cerr << "Error in XsltExecutable copy constructor" << std::endl;
84
            std::cerr << "Error in XsltExecutable copy constructor - parameter value is NULL" << std::endl;
85 85
        } else {
86 86
            parameters[paramIter->first] = new XdmValue(*(valuei));
87 87
        }
......
126 126
    if (_selection != nullptr) {
127 127
        _selection->incrementRefCount();
128 128
        selectionV = _selection;
129
        selection = _selection->getUnderlyingValue();
129
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(_selection->getUnderlyingValue());
130 130
    }
131 131
}
132 132

  
......
160 160
            it = parameters.find(skey);
161 161
            if (it != parameters.end()) {
162 162
                XdmValue *valuei = it->second;
163
                valuei->decrementRefCount();
164
                if (valuei != nullptr && valuei->getRefCount() < 1) {
165
                    delete value;
163
                if(valuei != nullptr) {
164
                    valuei->decrementRefCount();
165
                    if (valuei->getRefCount() < 1) {
166
                        delete value;
167
                    }
168
                    parameters.erase(skey);
169
                    parameters[skey] = value;
166 170
                }
167
                parameters.erase(skey);
168
                parameters[skey] = value;
169 171
            }
170 172
        }
171 173
    }
......
243 245
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
244 246

  
245 247
            XdmValue *value = itr->second;
246
            value->decrementRefCount();
248
            if(value != nullptr) {
249
                value->decrementRefCount();
247 250
#ifdef DEBUG
248
            std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
251
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
249 252
#endif
250
            if (value != nullptr && value->getRefCount() < 1) {
251
                delete value;
253
                if (value->getRefCount() < 1) {
254
                    delete value;
255
                }
252 256
            }
253 257
        }
254 258

  
......
258 262
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
259 263

  
260 264
            XdmValue *value = itr->second;
261
            value->decrementRefCount();
265
            if(value != nullptr) {
266
                value->decrementRefCount();
267
            }
262 268

  
263 269
        }
264 270

  
src/main/c/Saxon.C.API/XsltProcessor.cpp
129 129
            it = parameters.find(skey);
130 130
            if (it != parameters.end()) {
131 131
                XdmValue * valuei = it->second;
132
                valuei->decrementRefCount();
133
                if(valuei != nullptr && valuei->getRefCount() < 1){
134
                    delete value;
132
                if(valuei != nullptr) {
133
                    valuei->decrementRefCount();
134
                    if (valuei->getRefCount() < 1) {
135
                        delete value;
136
                    }
137
                    parameters.erase(skey);
138
                    parameters[skey] = value;
135 139
                }
136
                parameters.erase(skey);
137
                parameters[skey] = value;
138 140
            }
139 141
		}
140 142
	} 
......
183 185

  
184 186
void XsltProcessor::clearParameters(bool delValues) {
185 187
	if(delValues){
186
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
187
			
188
			XdmValue * value = itr->second;
189
			value->decrementRefCount();
188
       		for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
189

  
190
                XdmValue *value = itr->second;
191
                if (value != nullptr) {
192
                    value->decrementRefCount();
190 193
#ifdef DEBUG
191
			std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
194
                    std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
192 195
#endif
193
			if(value != nullptr && value->getRefCount() < 1){
194
	        		delete value;
195
			}
196
        	}
196
                    if (value->getRefCount() < 1) {
197
                        delete value;
198
                    }
199
                }
200
            }
197 201
		
198 202
	} else {
199
for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
203
        for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
200 204
		
201 205
			XdmValue * value = itr->second;
202
			value->decrementRefCount();
206
			if(value != nullptr) {
207
                value->decrementRefCount();
208
            }
203 209
		
204
        	}
210
        }
205 211

  
206 212
	}
207 213
	parameters.clear();
src/main/c/samples/cppTests/testXSLT30.cpp
121 121
void testApplyTemplatesString2(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
122 122

  
123 123
    cout << endl << "Test: testApplyTemplatesString2:" << endl;
124
    trans->clearParameters(true);
124
    trans->clearParameters();
125 125

  
126 126
    XdmNode *input = processor->parseXmlFromFile("cat.xml");
127 127

  
......
165 165
void testApplyTemplates2a(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
166 166

  
167 167
    cout << endl << "Test: TransformToString2a:" << endl;
168
    trans->clearParameters(true);
168
    trans->clearParameters();
169 169
    XdmNode *input = processor->parseXmlFromFile("cat.xml");
170 170

  
171 171
    if (input == nullptr) {
......
184 184
            cerr <<"testApplyTemplates2a error: "<< trans->getErrorMessage() << endl;
185 185
        }
186 186
        delete input;
187
        cerr<< "testApplyTemplates2a - cp0"<<endl;
188
        SaxonProcessor::sxn_environ->env->ExceptionDescribe();
187 189
        return;
188 190
    }
189 191

  
......
203 205
void testTransformToString2b(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
204 206

  
205 207
    cout << endl << "Test: TransformToString2b:" << endl;
206
    trans->clearParameters(true);
208
    trans->clearParameters();
207 209

  
208 210
    const char * result  = trans->transformFileToString("cat-error.xml", "test-error.xsl");
209 211

  
......
233 235
void testTransformToString3(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
234 236

  
235 237
    cout << endl << "Test: TransformToString3: param size=" << trans->getParameters().size() << endl;
236
    trans->clearParameters(true);
238
    trans->clearParameters();
237 239

  
238 240
    XdmNode *inputi = processor->parseXmlFromString(
239 241
            "<out><person>text1</person><person>text2</person><person>text3</person></out>");
240 242

  
241
    XdmAtomicValue *value1 = processor->makeIntegerValue(10);
242

  
243
    trans->setParameter("numParam", (XdmValue *) value1);
244

  
245 243
    if (inputi== nullptr) {
246 244
        cout << "Source document inputi is null. ====== FAIL ====== " << endl;
247 245
        sresult->failureList.push_back("testTransformToString3");
246

  
248 247
        return;
249 248
    }
250 249

  
250
    XdmAtomicValue *value1 = processor->makeIntegerValue(10);
251

  
252

  
253

  
251 254
    XsltExecutable * executable = trans->compileFromFile("test.xsl");
252 255

  
253 256
    if(executable== nullptr) {
......
261 264
        return;
262 265
    }
263 266

  
267

  
268

  
269
    trans->setParameter("numParam", (XdmValue *) value1);
270

  
271
    cerr << "testTransformToString3  test test " << endl;
272

  
264 273
    executable->setInitialMatchSelection((XdmNode *) inputi);
265 274
    const char *output = executable->applyTemplatesReturningString();
266 275
    if (output == nullptr) {
......
273 282
    }
274 283
    fflush(stdout);
275 284

  
285
    cout<<"value 1 object ref="<<(value1)<<endl;
276 286
    delete value1;
277 287
    delete executable;
278 288

  
......
288 298
    cout << endl << "cpp0-1" << endl;
289 299
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
290 300

  
291
    trans->clearParameters(true);
301
    trans->clearParameters();
292 302
    cout << endl << "cpp0-2" << endl;
293 303
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
294 304

  
......
346 356

  
347 357
void testTransformFromstring(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
348 358
    cout << endl << "Test: testTransfromFromstring: param size="<< trans->getParameters().size() << endl;
349
    trans->clearParameters(true);
359
    trans->clearParameters();
350 360
    if(processor == nullptr) {
351 361
        cout<<" processor is null"<<endl;
352 362
        return;
......
355 365
    XdmNode *input = processor->parseXmlFromString(
356 366
            "<out><person>text1</person><person>text2</person><person>text3</person></out>");
357 367

  
368
    if(input == nullptr) {
369
        sresult->failure++;
370
        sresult->failureList.push_back("testTransformFromstring");
371
        cerr << "testTransformFromstring NULL found" << endl;
372
        if (trans->exceptionOccurred()) {
373
            cerr <<"testTransformFromstring error: "<< trans->getErrorMessage() << endl;
374
        }
375
        return;
376
    }
377

  
358 378
    XsltExecutable * executable = trans->compileFromString(
359 379
            "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>       <xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' /><xsl:template match='*'><output><xsl:for-each select='$values' ><out><xsl:value-of select='. * 3'/></out></xsl:for-each></output></xsl:template></xsl:stylesheet>");
360 380

  
361
    if(executable== nullptr || input == nullptr) {
381
    if(executable== nullptr) {
362 382
        sresult->failure++;
363 383
        sresult->failureList.push_back("testTransformFromstring");
364 384
        cerr << "testTransformFromstring NULL found" << endl;
365 385
        if (trans->exceptionOccurred()) {
366 386
            cerr <<"testTransformFromstring error: "<< trans->getErrorMessage() << endl;
367 387
        }
388
        delete input;
368 389
        return;
369 390
    }
370 391

  
......
393 414
//Test case has error in the stylesheet
394 415
void testTransformFromstring2Err(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
395 416
    cout << endl << "Test: testTransfromFromstring2-Error:" << endl;
396
    trans->clearParameters(true);
417
    trans->clearParameters();
397 418

  
398 419
    XdmNode *input = processor->parseXmlFromString(
399 420
            "<out><person>text1</person><person>text2</person><person>text3</person></out>");
......
433 454
}
434 455

  
435 456
void testTrackingOfValueReference(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
436
    trans->clearParameters(true);
457
    trans->clearParameters();
437 458

  
438 459
    cout << endl << "Test: TrackingOfValueReference:" << endl;
439 460
    ostringstream test;
......
481 502

  
482 503
/*Test case should be error.*/
483 504
void testTrackingOfValueReferenceError(SaxonProcessor *processor, Xslt30Processor *trans, sResultCount *sresult) {
484
    trans->clearParameters(true);
505
    trans->clearParameters();
485 506

  
486 507
    cout << endl << "Test: TrackingOfValueReference-Error:" << endl;
487 508
    cout << "Parameter Map size: " << (trans->getParameters().size()) << endl;
......
533 554
}
534 555

  
535 556
void testValidation(Xslt30Processor *trans, sResultCount *sresult) {
536
    trans->clearParameters(true);
557
    trans->clearParameters();
537 558

  
538 559

  
539 560

  
......
558 579

  
559 580

  
560 581
void testXdmNodeOutput(Xslt30Processor *trans, sResultCount *sresult) {
561
    trans->clearParameters(true);
582
    trans->clearParameters();
562 583

  
563 584

  
564 585
    std::cout << "testXdmNodeOutput" << std::endl;
......
622 643
        cout << "Result is null ====== FAIL ====== " << endl;
623 644
        sresult->failure++;
624 645
    }
625
    proc->clearParameters(true);
646
    proc->clearParameters();
626 647
    delete executable;
627 648

  
628 649
}
......
644 665

  
645 666
        delete executable;
646 667
    }
647
    proc->clearParameters(true);
668
    proc->clearParameters();
648 669

  
649 670
}
650 671

  
......
681 702
        sresult->failure++;
682 703
        sresult->failureList.push_back("exampleSimple2");
683 704
    }
684
    proc->clearParameters(true);
685
    executable->clearParameters(true);
705
    proc->clearParameters();
706
    executable->clearParameters();
686 707
    delete executable;
687 708

  
688 709
}
689 710

  
690 711
void exampleSimple3(SaxonProcessor *saxonProc, Xslt30Processor *proc, sResultCount *sresult) {
691 712
    cout << "<b>exampleSimple3:</b><br/>" << endl;
692
    proc->clearParameters(true);
713
    proc->clearParameters();
693 714

  
694 715
    XsltExecutable * executable = proc->compileFromFile("../php/xsl/foo.xsl");
695 716

  
696
   if(executable== nullptr) {
717
   if(executable == nullptr) {
697 718
	cout << "executable is NULL" <<endl;
698 719
	if(proc->exceptionOccurred()) {
699 720
		cout << proc->getErrorMessage() <<endl;
700 721
		
701 722
	}
723

  
702 724
	return;
703 725

  
704 726
   }
......
712 734
    }
713 735
    executable->setInitialMatchSelection((XdmNode *) xdmNode);
714 736
    cout << "end of exampleSimple3" << endl;
715
    executable->clearParameters(true);
737
    executable->clearParameters();
716 738

  
717 739
    sresult->success++;
718 740
    delete executable;
719 741

  
742
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
743

  
720 744
}
721 745

  
722 746
void exampleSimple3a(SaxonProcessor *saxonProc, Xslt30Processor *proc, sResultCount *sresult) {
723
    cout << "<b>exampleSimple3:</b><br/>" << endl;
724
    proc->clearParameters(true);
747
    cout << "<b>exampleSimple3a:</b><br/>" << endl;
748
    proc->clearParameters();
725 749

  
726 750
    XsltExecutable * executable = proc->compileFromFile(nullptr);
727 751

  
......
730 754

  
731 755

  
732 756
        cout << "end of exampleSimple3a" << endl;
733
        proc->clearParameters(true);
757
        proc->clearParameters();
734 758

  
735 759
        sresult->success++;
736 760
        return;
......
892 916
            cout << proc->getErrorMessage() << endl;
893 917
        }
894 918
    }
895
    proc->clearParameters(true);
919
    proc->clearParameters();
896 920

  
897 921

  
898 922
}
......
914 938
            cout << proc->getErrorMessage() << endl;
915 939
        }
916 940
    }
917
    proc->clearParameters(true);
941
    proc->clearParameters();
918 942

  
919 943

  
920 944
}
......
935 959
            cout << proc->getErrorMessage() << endl;
936 960
        }
937 961
    }
938
    proc->clearParameters(true);
962
    proc->clearParameters();
939 963

  
940 964
}
941 965

  
......
946 970
void testPackage1(Xslt30Processor *trans, sResultCount *sresult) {
947 971

  
948 972
    cout << endl << "Test: Saving and loading Packages:" << endl;
949
    trans->clearParameters(true);
973
    trans->clearParameters();
950 974

  
951 975

  
952 976
    trans->compileFromFileAndSave("test.xsl", "test1.sef");
......
976 1000
void testPackage2(Xslt30Processor *trans, sResultCount *sresult) {
977 1001

  
978 1002
    cout << endl << "Test: Saving and loading Packages2 - Error:" << endl;
979
    trans->clearParameters(true);
1003
    trans->clearParameters();
980 1004

  
981 1005

  
982 1006
    const char *stylesheet = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>       <xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' /><xsl:template match='*'><output><xsl:for-each select='$values' ><out><xsl:value-of select='. * 3'/></out><xsl:for-each></output></xsl:template><xsl:stylesheet>";
......
1058 1082
        sresult->failure++;
1059 1083
    }
1060 1084

  
1061
    executable->clearParameters(true);
1085
    executable->clearParameters();
1062 1086
    delete result;
1063 1087
    delete executable;
1064 1088

  
......
1546 1570

  
1547 1571

  
1548 1572
    testCatalog(cwd, processor,  sresult);
1549
    processor->release();
1550
    return 0;
1573

  
1551 1574

  
1552 1575
    testTransformToString2b(processor, trans, sresult);
1553 1576

  
......
1555 1578
	
1556 1579
    testTransformFromstring(processor, trans, sresult);
1557 1580

  
1581
    processor->release();
1582
    delete processor;
1583
    return 0;
1584

  
1558 1585
    testTransformFromstring2Err(processor, trans, sresult);
1559 1586

  
1560 1587
    testTrackingOfValueReference(processor, trans, sresult);

Also available in: Unified diff