Re: core with unused OUT-structures/strings



Michael Haubenwallner wrote:
> 
> when i have OUT-structures, why is it necessary to initialize
> (MYSTRUCT__alloc) these though i return an error to signal the client
> not to use them ?
> 
> If i don't, ORBit2 cores when marshalling such structures by accessing
> NULL.
> 

The marshaller still expects valid out values, as it can't determine
that the caller is in error unless you throw an exception. Similarily,
with Java clients all out values must contain sane defaults even when
you're returning an error - things like the value of enumerated types
must be valid.

> Another problem is, if i have Strings in an OUT-structure, and even if
> i initialize (alloc) the OUT-structure itself, i have to alloc all the
> strings in the out-structure too or ORBit2 cores on strlen(NULL) when
> marshalling.
> 
> I strace'd GIOP-messages of mico-orb for C++, and when not using the
> out-variables (strings in structures), the returned strings are
> empty strings here (len=0) and other values are as of memset(,0,).
> 

That could be a consequence of MICO being written in C++ and using a
string class (either the systems STL or the included mini-stl if I'm not
mistaken). The constructor of the string class provides a "safe"
initialisation value I would imagine.

> Is it really necessary to initialize all strings in an OUT-structure
> with CORBA_string_dup(""), even if they are not used for some reasons ?
> 

That's exactly what I do. Again, I guess it's because the marshaller
expects valid out values - at least a "" string in this case. I seem to
recall the OMG specs frown upon NULL values because not all languages
are expected to have a suitable equivalent.

> If yes, a CORBA/ORBit-function which does this would be appreciated,
> since it is not always known which strings are in an OUT structure,
> due to some proprietary abstractions.
> 

Not sure what you mean here. Surely if you have the IDL then you can see
what structures contain strings?

> Why not default to the empty string if a string is NULL,
> IMHO would be better than core ?
> 

Chris
-- 
chris.wareham@iosystems.co.uk (work)
chris.wareham@btopenworld.com (home)




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