Re: Sequence being released?
- From: Michael Meeks <michael ximian com>
- To: Chris Roberts <croberts bongle co uk>
- Cc: orbit <orbit-list gnome org>
- Subject: Re: Sequence being released?
- Date: Mon, 15 Sep 2003 16:25:52 +0100
Hi Chris,
On Sun, 2003-09-14 at 12:11, Chris Roberts wrote:
> However, on the second call to this method, the _buffer variable is NULL.
> I've tried different ways of allocating the sequence, using the CORBA calls,
> and malloc and such, but it seems to me that ORBit is ignoring the _release
> flag and freeing the buffer anyway.
That would suck; the code that implements this is in:
ORBit2/src/orb/orb-core/allocators.c (ORBit_freekids_via_typecode) -
and it looks alright to me:
case CORBA_tk_sequence: {
CORBA_sequence_CORBA_octet *pval = mem;
if (pval->_release)
ORBit_free_T (pval->_buffer);
pval->_buffer = NULL;
retval = (guchar *)mem + sizeof(*pval);
break;
}
It paranoidly NULL's the copy you made's ->_buffer - but that shouldn't
affect the original at all.
Of course - we have to free the toplevel 'sequence' itself; I _believe_
release is only there to avoid re-allocating the _buffer rather than the
whole sequence; thus you need:
aRetval = foo_alloc;
aRetval->_release = FALSE;
aRetval->_buffer = main_foo->_buffer;
aRetval->...
Of course - unless this buffer is _Really_ static it's an incredibly
risky thing to do to poke with this, it's fraught with problems.
Particularly if a re-entering call updates / reallocs / moves _buffer
while the ORB is still trying to marshal the return value [ lower down
the stack perhaps ], or a similar situation with another thread - makes
it almost always better/cleaner just to dup/return.
HTH,
Michael.
--
michael@ximian.com <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]