<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=704203315-02052008><FONT face=Arial color=#0000ff size=2>Look
closely at the code - you're not actually returning anything (you need
*msg=&_message). You should still use the Message_out as the parameter
type, instead of Message* - you'll have less heartache down the
road.</FONT></SPAN></DIV>
<DIV><SPAN class=704203315-02052008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=704203315-02052008><FONT face=Arial color=#0000ff size=2>To the
best of my knowledge, only the _var and _ptr types deal with memory management -
I believe that the _out stores a copy of what you give it, but I'm not an expert
in this area by any stretch of the imagination. What you are doing should
be fine as long as you return something (assuming that you've initialized all of
_message's members somewhere).</FONT></SPAN></DIV>
<DIV><SPAN class=704203315-02052008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=704203315-02052008><FONT face=Arial color=#0000ff
size=2>-Bill</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
omniorb-list-bounces@omniorb-support.com
[mailto:omniorb-list-bounces@omniorb-support.com] <B>On Behalf Of </B>Tom
O'Reilly<BR><B>Sent:</B> Thursday, May 01, 2008 4:14 PM<BR><B>To:</B> Tom
O'Reilly; Luke Deller<BR><B>Cc:</B>
omniorb-list@omniorb-support.com<BR><B>Subject:</B> Re: [omniORB] Can't
compile client that retrieves astructwhichcontains a
sequence<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Ah, I see now.</FONT></DIV>
<DIV><FONT face=Arial size=2>The server implementation must allocate a
SequenceTestIF::Message on the heap (using new operator), since the CORBA
framework will automatically try to delete it after the function call is
complete - right?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Tom</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=oreilly@mbari.org href="mailto:oreilly@mbari.org">Tom O'Reilly</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=ldeller@iress.com.au
href="mailto:ldeller@iress.com.au">Luke Deller</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A
title=omniorb-list@omniorb-support.com
href="mailto:omniorb-list@omniorb-support.com">omniorb-list@omniorb-support.com</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, May 01, 2008 11:45
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [omniORB] Can't compile
client that retrieves a structwhichcontains a sequence</DIV>
<DIV><BR></DIV>
<DIV><BR><FONT face=Arial size=2>> So you don't actually construct a
Message_out instance explicitly. Basically you want to pass a
reference to a </FONT></DIV>
<DIV><FONT face=Arial size=2>> pointer, so that the function can point
your pointer at the returned message:</FONT></DIV>
<DIV><FONT face=Arial size=2>><BR>><BR>>
SequenceTestIF::Message *msgptr;<BR>>
seqTest->getMessage(msgptr);<BR>> // now you can use
msgptr->body<BR>>
seqTest->setMessage(*msgptr);<BR>> delete
msgptr;<BR><BR>OK, but I'm still a bit confused. What does the server
implementation code do with the passed-in msgptr, which is null (it IS null
to start with, right?) Is it something like this:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2> Server code:</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2> class SequenceTestServer
{</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2> void
getMessage(SequenceTestIF::Message *msg() {</FONT></DIV>
<DIV><FONT face="Courier New"
size=2> msg =
&_message;</FONT></DIV>
<DIV><FONT face="Courier New"
size=2>
return; <FONT color=#ff0000>// Server
encounters seg-fault after return statement.</FONT></FONT></DIV>
<DIV><FONT face="Courier New" size=2> }</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2> // Define a
Message member</FONT></DIV>
<DIV><FONT face="Courier New" size=2>
SequenceTestIF::Message _message;</FONT></DIV>
<DIV><FONT face="Courier New" size=2> };</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I tried something like this, but the server
gets a segmentation fault after returning from getMessage().</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Many thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Tom</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>omniORB-list
mailing
list<BR>omniORB-list@omniorb-support.com<BR>http://www.omniorb-support.com/mailman/listinfo/omniorb-list<BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>