memory leak ?



Hi,

I allocate a structure "EzxRdrImgObj" and an "embedded" octet sequnce
"EzxRdrImgBuf" on the ORBit server side and return the structure to the
client where I transfer the content of the sequence to an "image" buffer
and afterwards relase the sequence with "CORBA_free( img->data._buffer
)", however freeing the structure (retunr value) with CORBA_free gives
me a segmentation violation. If i use "free" it dos not crash, but it
doens't seem to free the meory either. I have pasted the source code of
the client routine below.

I thought that sequentialy freeing first the embedded octet sequence and
then the structure itself would do the job ? I am now testing the
behaviour of the sytem, so not everything has been completed, but the
transfer of image data should work ?

The image reading routine in the server:
impl_EzxS_Srvr_ReadImage(impl_POA_EzxS_Srvr * servant,
EzxS_EzxRdrDatastoreObj * Ezxstrg, CORBA_char ** message,
CORBA_Environment * ev)

I set "release" to FALSE in the server for the sequence has to be
returned to the client for readout before being released in the client.

e.g.:
typedef sequence<octet> EzxRdrImgBuf;

struct EzxRdrImgObj {
        char name[64];
        EzxRdrImgBuf data;
        short type;
        long width;
        long height;
        long depth;
        long slice;
        short axis;
        long clut;
};


Best regards,

Peter Van Osta


=======================================================================

static gboolean ezx_read_image( guchar *im, guchar *name, gint width,
gint height )

{
	Ezx_EzxImgObj *img = NULL;
	Ezx_EzxRdrDatastoreObj strg;
	CORBA_char *message = NULL;
	gint loops = 0, size = 0;
	CORBA_octet *pin = NULL;
	guchar *pout = NULL;

	strcpy( strg.name, name );
	img = Ezx_Srvr_ReadImage( server, &strg, &message, &ev );
	
	size = ( gint )img->data._length;
	loops = width * height;
	pin = img->data._buffer;
	pout = im;
	
	/* Always convert to RGB for output */
	do{
		*pout++ = ( guchar )( *pin );
		*pout++ = ( guchar )( *pin );
		*pout++ = ( guchar )( *pin++ );
	} while( loops-- );

	if( message )
		CORBA_free( message );

	if( img->data._buffer )
		CORBA_free( img->data._buffer );
	free( img );

	return( TRUE );
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]