[Ptinpoly-commits] r30 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 26 03:24:30 CEST 2014
Author: jmaisog
Date: 2014-08-26 03:24:29 +0200 (Tue, 26 Aug 2014)
New Revision: 30
Modified:
pkg/src/pinpolyhedronA.cc
Log:
Clarifying the memory allocation of arrays of triplets of ints and doubles. Jianfei and I doubt that this will fix the memory leak, but Jianfei has asked me to try it.
Modified: pkg/src/pinpolyhedronA.cc
===================================================================
--- pkg/src/pinpolyhedronA.cc 2014-08-20 13:02:28 UTC (rev 29)
+++ pkg/src/pinpolyhedronA.cc 2014-08-26 01:24:29 UTC (rev 30)
@@ -361,13 +361,16 @@
// epsilonon=epsion;
numvert=numvi;
- vertcoord=(double (*)[3]) new double[3*numvert];
+// vertcoord=(double (*)[3]) new double[3*numvert];
+ vertcoord = new double[numvert] [3];
memcpy(vertcoord,vti,sizeof(double)*3*numvert);
numtri=numti;
- trips=(int (*)[3])new int[3*numtri];
+// trips=(int (*)[3])new int[3*numtri];
+ trips = new int[numtri] [3];
memcpy(trips, tris,sizeof(int)*3*numtri);
- tneighb=(int (*)[3]) new int [3*numtri];
+// tneighb=(int (*)[3]) new int [3*numtri];
+ tneighb = new int[numtri] [3];
triofnode=(int *) new int[numvert];
vertattrib= new int [numvert];
for(int i=0; i<numvert; i++)
@@ -724,7 +727,8 @@
//Rprintf("PIP_jianfei_cpp: entered C++ function.\n");
// Transfer vertex data from flat double array to double[3] array.
double (*vert)[3];
- vert = ( double (*)[3]) new double [3*(*numV)];
+// vert = ( double (*)[3]) new double [3*(*numV)];
+ vert = new double[*numV] [3];
#if 0
double minX = DLB_MAX, minY=DBL_MAX, minZ=DBL_MAX;
#else
@@ -751,7 +755,8 @@
// Transfer face data from flat int array to int[3] array.
// Decrement vertex indices by 1, since Jianfei's code starts indexing at 0.
int (*tris)[3];
- tris = (int (*)[3]) new int [3*(*numF)];
+// tris = (int (*)[3]) new int [3*(*numF)];
+ tris = new int[*numF] [3];
for( i=0; i<(*numF); i++) {
tris[i][0] = faces[i+0*(*numF)] - 1;
tris[i][1] = faces[i+1*(*numF)] - 1;
@@ -1904,7 +1909,8 @@
//Rprintf("PIP_jianfei_cpp: entered C++ function.\n");
// Transfer vertex data from flat double array to double[3] array.
double (*vert)[2];
- vert = ( double (*)[2]) new double [2*(*numV)];
+// vert = ( double (*)[2]) new double [2*(*numV)];
+ vert = new double[*numV] [2];
#if 0
double minX = DLB_MAX, minY=DBL_MAX;
#else
More information about the Ptinpoly-commits
mailing list