deallocation problem or conflict ?



Hi,

I am currently working on transferring image data from the ORBit server
to the client application, but I am getting segmentation violations when
freeing an image buffer on the server. I use an image library to read
the image data into a buffer and I then copy the data in to an octet
sequence. After the copying is done I free the original "image" buffer,
which is a non-ORBit data structure.

The calls to read the iamge from disk and to free the data afterwards,
have nothing to do with ORBit and when used in the "server" without any
ORBit code in between the "reading" and the "destryoing" everything
works fine.

IMAGE *rdimg = NULL;
rdimg = readfile( "cermet", NULL, 0, 0 );
destroy_image( rdimg );

The original image in this case is a 16bit greyvalue of the internal
type "PIXEL". The data structures in which I put the data are shown here
and the source code on the server side is shown below. I am also puzzled
how to free the return value "EzxRdrImgObj" on the client side after the
transfer of the image data to the client.

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 EzxS_EzxRdrImgObj *
impl_EzxS_Srvr_ReadImage(impl_POA_EzxS_Srvr * servant,
			 EzxS_EzxRdrDatastoreObj * Ezxstrg,
			 CORBA_char ** message, CORBA_Environment * ev)
{
	IMAGE *rdimg;
	PIXEL *p = NULL;
	RGB *r = NULL;
	CORBA_octet *o = NULL;
	int size = 0;
	EzxS_EzxRdrImgObj *retval;
	*message = CORBA_string_dup( "Nothing" );

	retval = EzxS_EzxRdrImgObj__alloc( );
   
	rdimg = readfile( "cermet", NULL, 0, 0 );
	if( !rdimg )
		fprintf( stderr, "Failed to allocate image\n" );
	
	retval->type = ( CORBA_short )ImageTypeIdent( rdimg );	
	retval->width = ( CORBA_long )ImageWidth( rdimg );
	retval->height = ( CORBA_long )ImageHeight( rdimg );
	retval->depth = ( CORBA_long )ImageDepth( rdimg );
	retval->slice = 0;
	
	size = ImageWidth( rdimg ) * ImageHeight( rdimg ) * ImageDepth( rdimg
);
   
  	switch( ImageTypeIdent( rdimg ) ){
		case GREY_2D:
		case GREY_3D:
			retval->data._maximum = size + 1;
			retval->data._length = size;
			retval->data._buffer = CORBA_sequence_CORBA_octet_allocbuf(
retval->data._length );
		break;
		case COLOR_2D:
		case COLOR_3D:
			retval->data._maximum = ( size * 3 ) + 4;
			retval->data._length = size * 3;
			retval->data._buffer = CORBA_sequence_CORBA_octet_allocbuf(
retval->data._length );
		break;
		default:
		break;
	}
	
	o = retval->data._buffer;
  	switch( ImageTypeIdent( rdimg ) ){
		case GREY_2D:
		case GREY_3D:
			p = ImageOutData( rdimg );
			do{
				*o++ = ( CORBA_octet )( *p++ );	
			} while( size-- );
		break;
		case COLOR_2D:
		case COLOR_3D:
			r = ImageOutData( rdimg );
			do{
				*o++ = ( CORBA_octet )Red( r );	
				*o++ = ( CORBA_octet )Green( r );	
				*o++ = ( CORBA_octet )Blue( r );
				r++;	
			} while( size-- );
		break;
		default:
		break;
	}
	
	retval->data._release = ( CORBA_boolean )FALSE;
	CORBA_sequence_set_release( &( retval->data ), FALSE );

	return( retval );
}



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