Re: TypeCode operations



Michael Meeks <michael@ximian.com> wrote:
> 	Strange. If the spec says to return a CORBA_any * it is implicit that
> the caller must free it.

There are other types that the caller must free too - everything except
the primitive types and fixed length structs and unions.

Actually, the caller is responsible for allocating memory for primitives
and fixed length structs and unions in the first place, so it's still up
to the caller to free them. It's just more obvious. And they're usually
on the stack, which makes allocation and deallocation automatic.

Anyway...

> 	Perhaps in perception. Anything returned from a CORBA like method,
> specified in PIDL will obey the normal CORBA return / out semantics.

Hrm. Okay, let me give you an example, lifted from the TypeCode stuff
that I copied from STABLE. This is the last line of CORBA_TypeCode_id():

return (CORBA_RepositoryId)obj->repo_id;

That's returning a pointer to the struct member. From what I can see in
the spec, the caller is supposed to release that when they're done.
They're not allowed to modify the memory, but they have to release it.
Now, the returned type is a string object. Since strings don't have
reference counts, CORBA_TypeCode_id() should return the value from a
call to CORBA_string_dup() instead.

So, am I wrong in my reasoning somewhere? If I'm right, then each of the
TypeCode operations that returns a string or TypeCode needs to be fixed.

And then the tests should be modified, because I think a lot of them
don't release stuff that they really should.
-- 
Sam "Eddie" Couter  |  mailto:scouter@bigpond.net.au
Debian Developer    |  mailto:eddie@debian.org
                    |  jabber:sam@jabber.topic.com.au
OpenPGP fingerprint:  A46B 9BB5 3148 7BEA 1F05  5BD5 8530 03AE DE89 C75C

PGP signature



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