Re: transfer of structures with strings



Hi Peter,

On Tue, 2003-10-21 at 16:24, Peter Van Osta wrote:
> I was a bit puzzled by problems (segmentation violations) caused by 
> transferring structures which contained strings.

	Interesting.

> For the incoming "in" structures I thought that the following would do 
> to copy the entire structure, but this seemed to be a wrong idea:
> 
> local_struct = ORBit_copy_value( remote_struct, TC_XXX );

	This should work fine; and I'd recommend it as the way to persist a
complex structure outside the method invocation.

	Of course; 'remote_struct' must be a Foo_Struct * pointer, and the
typecode must be equivalent: TC_Foo_Struct (clearly).

> On both the server and the client side "strcpy" and "sprintf' can be 
> used, as long as "CORBA_string_dup" is used when a transfer over the 
> CORBA link is needed.

	Sure; OTOH - strcpy, sprintf are horribly unsafe API for people
uncertain about memory management. I'd strongly recommend using:

	new_str = g_str_concat( str_one, str_two, str_three, NULL);
	NB. don't forget the NULL; g_free the allocated result

	Also:

	new_str = g_strdup_printf ("Hello %s", foo_str);

	is _far_ safer / easier than sprintf.

> Everything seems to run smoothly now and the final tests are running.

	Great,

	Regards,

		Michael.

-- 
 michael@ximian.com  <><, Pseudo Engineer, itinerant idiot




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