|
From: <and...@us...> - 2012-01-05 11:58:31
|
Revision: 12121
http://plplot.svn.sourceforge.net/plplot/?rev=12121&view=rev
Author: andrewross
Date: 2012-01-05 11:58:24 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
Potential fix for java crashes with pltr2 to avoid referencing variables that are out of scope.
Modified Paths:
--------------
trunk/bindings/java/plplotjavac.i
Modified: trunk/bindings/java/plplotjavac.i
===================================================================
--- trunk/bindings/java/plplotjavac.i 2012-01-05 11:51:21 UTC (rev 12120)
+++ trunk/bindings/java/plplotjavac.i 2012-01-05 11:58:24 UTC (rev 12121)
@@ -330,6 +330,7 @@
static PLINT Xlen = 0, Ylen = 0;
static PLFLT **xg;
static PLFLT **yg;
+ static PLcGrid2 *cgrid;
%}
// The following typemaps take care of marshaling values into and out of PLplot functions. The
@@ -1536,7 +1537,6 @@
int nx = ( *jenv )->GetArrayLength( jenv, $input );
int ny = -1;
int i, j;
- PLcGrid2 cgrid;
ai = (jobject *) malloc( nx * sizeof ( jobject ) );
adat = (jPLFLT **) malloc( nx * sizeof ( jPLFLT * ) );
@@ -1580,16 +1580,18 @@
free( adat );
free( ai );
- cgrid.xg = xg;
- cgrid.yg = yg;
- cgrid.nx = nx;
- cgrid.ny = ny;
- $1 = &cgrid;
+ cgrid = (PLcGrid2 *) malloc( sizeof ( PLcGrid2 ) );
+ cgrid->xg = xg;
+ cgrid->yg = yg;
+ cgrid->nx = nx;
+ cgrid->ny = ny;
+ $1 = cgrid;
}
%typemap( freearg ) PLPointer OBJECT_DATA {
free( yg[0] );
free( yg );
+ free( cgrid );
}
%typemap( jni ) PLPointer OBJECT_DATA "jobjectArray"
%typemap( jtype ) PLPointer OBJECT_DATA jPLFLTbracket2
@@ -1679,7 +1681,6 @@
int nx = ( *jenv )->GetArrayLength( jenv, $input );
int ny = -1;
int i, j;
- PLcGrid2 cgrid;
ai = (jobject *) malloc( nx * sizeof ( jobject ) );
adat = (jPLFLT **) malloc( nx * sizeof ( jPLFLT * ) );
@@ -1723,16 +1724,18 @@
free( adat );
free( ai );
- cgrid.xg = xg;
- cgrid.yg = yg;
- cgrid.nx = nx;
- cgrid.ny = ny;
- $1 = &cgrid;
+ cgrid = (PLcGrid2 *) malloc( sizeof ( PLcGrid2 ) );
+ cgrid->xg = xg;
+ cgrid->yg = yg;
+ cgrid->nx = nx;
+ cgrid->ny = ny;
+ $1 = cgrid;
}
%typemap( freearg ) PLPointer OBJECT_DATA_img {
free( yg[0] );
free( yg );
+ free( cgrid );
}
%typemap( jni ) PLPointer OBJECT_DATA_img "jobjectArray"
%typemap( jtype ) PLPointer OBJECT_DATA_img jPLFLTbracket2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|