Project

Profile

Help

Revision 6304fb8b

Added by O'Neil Delpratt 5 months ago

Saxon/C bug fixes and development work

View differences:

latest10/hec/Saxon.C.API/XdmValue.cpp
30 30
		if (!strMID2) {
31 31
			std::cerr << "Error: Saxonc.XdmValue." << "toString"
32 32
				<< " not found\n" << std::endl;
33
			return NULL;
33
			return nullptr;
34 34
		}
35 35
		else {
36 36
			for(int i=0; i<size();i++) {
......
38 38
			
39 39
				jstring result = (jstring)(SaxonProcessor::sxn_environ->env->CallObjectMethod(itemAt(i)->getUnderlyingValue(), strMID2));
40 40
				if (result) {
41
					toStringValue += SaxonProcessor::sxn_environ->env->GetStringUTFChars(result, NULL);
41
					toStringValue += SaxonProcessor::sxn_environ->env->GetStringUTFChars(result, nullptr);
42 42
					SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
43 43
				
44 44
				}
......
69 69
	values.resize(0);//TODO memory issue might occur here
70 70
	values.push_back(value);
71 71
	xdmSize++;
72
	jValues = NULL;
73
	valueType = NULL;
72
	jValues = nullptr;
73
	valueType = nullptr;
74 74
}
75 75

  
76 76

  
77 77
XdmValue::XdmValue(jobject val, bool arr){
78 78
	xdmSize = 0;
79 79
	values.resize(0);
80
	jValues = NULL;
81
	valueType = NULL;
80
	jValues = nullptr;
81
	valueType = nullptr;
82 82
	jclass xdmValueForcppClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp");
83 83
	jmethodID xvfMID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(xdmValueForcppClass, "makeArrayFromXdmValue", "(Lnet/sf/saxon/s9api/XdmValue;)[Lnet/sf/saxon/s9api/XdmItem;");
84 84

  
......
99 99

  
100 100
		//XdmValue * value = new XdmValue();
101 101
		//value->setProcessor(proc);
102
		XdmItem * xdmItem = NULL;
102
		XdmItem * xdmItem = nullptr;
103 103
		for (int p=0; p < sizex; ++p) 
104 104
		{
105 105
			jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
......
134 134
    if(getRefCount()<1){
135 135
	//proc->env->ReleaseObject
136 136
	for (size_t i = 0; i < values.size(); i++) {
137
		if (values[i] != NULL && values[i]->getRefCount() < 1) {
137
		if (values[i] != nullptr && values[i]->getRefCount() < 1) {
138 138
			delete values[i];
139 139
			safeToClear = true;
140 140
		} else {
......
144 144
	if(safeToClear) {
145 145
		values.clear();
146 146
	}
147
	if (valueType != NULL) { delete valueType; }
148
	if (jValues && proc != NULL) {
147
	if (valueType != nullptr) { delete valueType; }
148
	if (jValues && proc != nullptr) {
149 149
		SaxonProcessor::sxn_environ->env->DeleteLocalRef(jValues);  //TODO check - this maybe should be DeleteGlobalRef  - check where it is created
150 150
	}
151 151
	xdmSize = 0;
......
157 157
}
158 158

  
159 159
void XdmValue::addXdmItem(XdmItem* val) {
160
	if (val != NULL) {
160
	if (val != nullptr) {
161 161
		values.push_back(val);
162 162
		xdmSize++;
163
		jValues = NULL; //TODO clear jni array from memory if needed
163
		jValues = nullptr; //TODO clear jni array from memory if needed
164 164
	}
165 165
}
166 166

  
......
170 170
	valuei->setProcessor(proc);
171 171
	values.push_back(valuei);
172 172
	xdmSize++;
173
	jValues = NULL; //TODO clear jni array from memory if needed
173
	jValues = nullptr; //TODO clear jni array from memory if needed
174 174

  
175 175
}
176 176

  
......
193 193
		return values[0];
194 194
	}
195 195
	else {
196
		return NULL;
196
		return nullptr;
197 197
	}
198 198
}
199 199

  
200 200
jobject XdmValue::getUnderlyingValue() {
201
	if (jValues == NULL) {
201
	if (jValues == nullptr) {
202 202
		int i;
203 203
		JNIEnv *env = SaxonProcessor::sxn_environ->env;
204 204
		int count = values.size();
205 205
		if (count == 0) {
206
			return NULL;
206
			return nullptr;
207 207
		}
208 208
		jclass objectClass = lookForClass(env,
209 209
			"net/sf/saxon/s9api/XdmItem");
......
226 226
	if (n >= 0 && (unsigned int)n < values.size()) {
227 227
		return values[n];
228 228
	}
229
	return NULL;
229
	return nullptr;
230 230
}
231 231

  
232 232
/**

Also available in: Unified diff