problem with free function

Collewet Guylaine guylaine.collewet at cemagref.fr
Fri Feb 11 17:22:27 CET 2011


Hello,

 

I have a problem with the "free" function which makes scilab crash

I wrote two functions "sci_imdilate" and "image_dilate"

sci_imdilate is the interface between scilab and the function
image_dilate

 

the memory pointed by l_dilated_image (see the code below) is allocated
by image_dilate and I'd like to free it in sci_imdilate

 

however, a call to free makes  scilab crash

If I remove the "free", the whole function works properly

 

I cannot undersand why

 

Does someone see my mistake ?

I am working with scilab 5.2.2  32 bits on windows 7 (64 bits machine)

 

Regards

 

Guylaine Collewet

 

 

 

/////////////////////////

// function sci_imdilate

///////////////////////

 

double *l_dilated_image;

 

.../...

 

dilate_image(&l_image[0], m_image, n_image, &l_kernel[0], m_kernel,
n_kernel, &l_dilated_image, &l_mask[0], &ierr);

 

createMatrixOfDouble(pvApiCtx, 4, m_image, n_image, l_dilated_image);

 

if(l_dilated_image) {

       free(l_dilated_image);

               }

 

 

 

/////////////////////////

// function dilate_image

/////////////////////////

 

 

int dilate_image(double *image, int width, int height, double *kernel,
int kernel_width, int kernel_height, double **dilated_image, double
*mask, int *ierr)

{

 

.../...

 

               if (!(*dilated_image = (double*)calloc(1,
sizeof(double)*width*height)))

               {

                              *ierr=1;

                              return(-1);

               }

 

 

.../...

 

 

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110211/2c580d32/attachment.htm>


More information about the users mailing list