Re: a questiong about the return value type "CORBA_char *"
- From: Michael Meeks <michael ximian com>
- To: folke sina com cn
- Cc: orbit <orbit-list gnome org>
- Subject: Re: a questiong about the return value type "CORBA_char *"
- Date: 17 Dec 2002 13:44:52 +0000
Hi Folke,
On Tue, 2002-12-17 at 09:24, folke@sina.com.cn wrote:
> i am a new comer of this community.
> i want to make some questions clear :)
These are rather basic C questions - it'd be more appropriate to ask
these on the 'gnome-love' list I think.
> CORBA_char *
> BasicServer__get_foo(PortableServer_Servant servant,
> CORBA_Environment *ev) {
> return CORBA_string_dup(constants_STRING_RETN);
> }
...
> CORBA_string_dup() will allocate a new memory block,
> which will be freed by the system after the
> BasicServer__get_foo() returns, is that it?
Quite correct.
> if so how about the following procedure:
>
> static
> CORBA_char *
> BasicServer__get_foo(PortableServer_Servant servant,
> CORBA_Environment *ev) {
>
> CORBA_char *retval;
>
> retval = CORBA_string_dup(constants_STRING_RETN);
> /* do something interesting here */
> return retval;
> }
Compile this without any debugging symbols with -O2 and do a binary
diff on the output.
> the only modification is i defined a temporary variable
> "retval", i wonder whether this procedure is quite the
> same as the first one ? That is , whether the memory
> block pointed by the retval will be freed automatically
> by the system after the BasicServer__get_foo() returns?
C is a low level language - what you see is what you get; an assignment
of a pointer, just copies the pointer into another bit of stack - there
is no magic.
Regards,
Michael.
--
mmeeks@gnu.org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]