Revision 32079

View differences:

branches/v2_0_0_prep/libraries/libjni-gdal/src/main/native/jgdal/gdal_interfaz.c
56 56
#include "cpl_string.h"
57 57
#include "signal.h"
58 58

  
59

  
60

  
61 59
/******************************************************************************/
62 60
//								Open
63 61
/******************************************************************************/
......
106 104
	#endif
107 105
}
108 106

  
107

  
108

  
109 109
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_Gdal_openArrayNat
110 110
  (JNIEnv *env, jobject obj, jbyteArray pszF, jint acc){
111 111
  	
......
117 117
  	jsize longitud = 0, i;
118 118
 	  	
119 119
  	longitud = (*env)->GetArrayLength(env, pszF); 
120
  	pszFilename = (*env)->GetByteArrayElements(env, pszF, 0);
120
	pszFilename = (*env)->GetByteArrayElements(env, pszF, 0);
121 121
  	
122
  	#ifdef __linux__
123
		pszFilename = (jbyte *)realloc(pszFilename, longitud + 1);
124
	#else
125
		aux = (jbyte *)malloc(sizeof(jbyte) * (longitud + 1));
126
	  	memcpy(aux, pszFilename, longitud);
127
	  	free(pszFilename);
128
	  	pszFilename = aux;
129
	#endif
122
	aux = (jbyte *)malloc(sizeof(jbyte) * (longitud + 1));
123
  	memcpy(aux, pszFilename, longitud);
124
	(*env)->ReleaseByteArrayElements(env, pszF, pszFilename, 0);
125
  	pszFilename = aux;
130 126
  		
131 127
	pszFilename[longitud] = '\0';
132 128
	
......
138 134
   	
139 135
   	GDALAllRegister();
140 136
  	dataset = GDALOpen((char *)pszFilename,(int)acc);
137

  
138
	// rgaitan: Aquí pszFilename ya no apunta al array de java, 
139
	// es el de aux, por lo que tenemos que liberarlo.
140
	// este cambio se ha realizado en todas las librerías jni que utilizan
141
	// el método "array" para abrir ficheros.
142
	free(pszFilename);
141 143
  	
142 144
  	*(GDALDatasetH **)&jresult = dataset;
143 145
  	
144
    (*env)->ReleaseByteArrayElements(env, pszF, pszFilename, 0);
145
  	
146 146
  	if(dataset == NULL)
147 147
  		return -1; 
148 148
  	else 
branches/v2_0_0_prep/libraries/libjni-gdal/src/main/native/jgdal/warpfunc.cpp
156 156

  
157 157
	jclass newExcCls = env->FindClass("es/gva/cit/jgdal/GdalException");
158 158
	if (newExcCls == 0)
159
		return 0;
159
		return CE_Failure;
160 160

  
161 161
	env->ThrowNew(newExcCls, msg);
162
	return 0;
162
	return CE_Failure;
163 163
}
164 164

  
165 165
int warpFunction(JNIEnv *env, char * s_srs, char * t_srs, char *source, char * dest, char *format) {
......
182 182
	const char *pszDstNodata = NULL;
183 183
	int bMulti = FALSE;
184 184
	char error[1024];
185
        int result = 4;
185 186

  
186 187
	GDALAllRegister();
187 188

  
......
450 451

  
451 452
			GDALDestroyDriverManager();
452 453

  
453
			return 1;
454
			return CE_None;
454 455
		}
455 456

  
456 457
/* -------------------------------------------------------------------- */
457 458
/*      Initialize and execute the warp.                                */
458 459
/* -------------------------------------------------------------------- */
459 460
		GDALWarpOperation oWO;
460

  
461
		result = CE_None;
461 462
		if (oWO.Initialize(psWO) == CE_None) {
462 463
			if (bMulti) {
463
				oWO.ChunkAndWarpMulti(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));
464
				result = oWO.ChunkAndWarpMulti(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));
464 465
			} else {
465
				oWO.ChunkAndWarpImage(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));
466
				result = oWO.ChunkAndWarpImage(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));
466 467
			}
467
		}
468
		} else
469
			result = CE_Failure;
468 470

  
469 471
/* -------------------------------------------------------------------- */
470 472
/*      Cleanup                                                         */
......
492 494

  
493 495
	GDALDestroyDriverManager();
494 496

  
495
	return 1;
497
	return result;
496 498
}
497 499

  
498 500

  
branches/v2_0_0_prep/libraries/libjni-gdal/src/main/native/jgdal/gdalwarp_interfaz.cpp
50 50
	const char * src;
51 51
	const char * dst;
52 52
	const char * form;
53
	int stat = 0;
53
	int stat = 2;
54 54

  
55 55
	proj = (env)->GetStringUTFChars(newProj, 0);
56 56
	src = (env)->GetStringUTFChars(source, 0);

Also available in: Unified diff