changeset 1061:c214d14684eb octave-forge

fix possible memory leak
author schloegl
date Sat, 27 Sep 2003 19:32:57 +0000
parents 30adec23a478
children 9449d28f1d90
files extra/NaN/sumskipnan2.cpp
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/extra/NaN/sumskipnan2.cpp	Sat Sep 27 09:45:12 2003 +0000
+++ b/extra/NaN/sumskipnan2.cpp	Sat Sep 27 19:32:57 2003 +0000
@@ -110,6 +110,7 @@
 	if (DIM < 1) DIM=1;		// in case DIM is still undefined 
 
 	ND2 = (ND>DIM ? ND : DIM);	// number of dimensions of output 
+
 	SZ2 = (int*)mxCalloc(ND2, sizeof(int)); // allocate memory for output size
 
 	for (j=0; j<ND; j++)		// copy size of input;  
@@ -123,7 +124,6 @@
 
 	SZ2[DIM-1] = 1;		// size of output is same as size of input but SZ(DIM)=1;
 
-
 	    // create outputs
 	#define TYP mxDOUBLE_CLASS
 
@@ -150,6 +150,7 @@
         	LOutputSum4  = mxGetPr(POutput[3]);
     	}
 
+	mxFree(SZ2);
 
 	// OUTER LOOP: along dimensions > DIM
 	for (l = 0; l<D3; l++) 	
@@ -206,10 +207,9 @@
 			            	mexErrMsgTxt("Number of NaNs is different for REAL and IMAG part");
 	            		if (POutputCount >= 3)
         	        		LOutputSum2[ix2] += LSum2;
-			}	
+			}
 		}
 	}
-	mxFree(SZ2);    	
 }