[omniORB] Passing strings to functions
David Bellette
david.bellette@nec.com.au
Thu, 6 Dec 2001 17:12:34 +1100
This is a multi-part message in MIME format.
------=_NextPart_000_0043_01C17E79.32A03FB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm new to corba, so forgive me for my simple question, but if anyone =
can help, it would be creately appreciated.
I have some code implemented on 2 versions of corba - one works fine, =
the other causes a heap exception. The one causing the heap exception is =
using omniOrb, hence my post on this list.
The example is from the first example in the omniOrb manual, so it's =
frustating the basic examples don't even work.
The following code, I have implemented as a servant using omniOrb, but =
is causes a heap exception on exiting, which I believe is due to the =
cleanup of the passed in string.
char* Echo_i::echoString(const char* inString)
{
// this crashes!
CORBA::String_var lRet =3D inString; // deep copy
//return lRet; // incorrect - this causes a release of =
the returned object's memory=20
return lRet._retn(); // correct way - free is not called
}
I've tried using:
CORBA::String_var lRet =3D CORBA::string_dup(inString);
with the same result.
I've also tried :
void Echo_i::echoString(const char* inString)
{
// do nothing
}
and this has the same problem, so it doesn't appear to be anything to =
dow ith my string handling...
It seems whenever I use a string as an in, the server has this problem. =
I've also tried specifying the string as an inout and I get the same =
result.
I have implemented the following using Orbacus and it works fine:
char* Hello_impl::echo(const char* pInString)
// echos the sent string
{
// works fine
CORBA_String_var lRet =3D pInString;
return lRet._retn();
}
For such a simple task, this is frustating me somewhat.=20
I have managed to send long's as in's without any problems, and I have =
strings as returns, without any problems - it's just when a string is =
passed to a function.
If anyone can assist, I'd be very grateful.
I'm using omniOrb 3.04 on a Windows NT4 platform.
Thank you
David
-------------------------------------------------------------------------=
---------------------------
David Bellette =20
Senior Software Engineer
NEC Business Solutions Pty. Ltd.
Australia
Email : david.bellette@nec.com.au
-------------------------------------------------------------------------=
---------------------------
------=_NextPart_000_0043_01C17E79.32A03FB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>I'm new to corba, so forgive me for my simple question, but if =
anyone can=20
help, it would be creately appreciated.</DIV>
<DIV> </DIV>
<DIV>I have some code implemented on 2 versions of corba - one =
works fine,=20
the other causes a heap exception. The one causing the heap exception is =
using=20
omniOrb, hence my post on this list.</DIV>
<DIV>The example is from the first example in the omniOrb manual, so =
it's=20
frustating the basic examples don't even work.</DIV>
<DIV> </DIV>
<DIV>The following code, I have implemented as a servant using =
omniOrb, but=20
is causes a heap exception on exiting, which I believe is due to the =
cleanup of=20
the passed in string.</DIV>
<DIV> </DIV>
<DIV>char* Echo_i::echoString(const char* =
inString)<BR>{<BR> =20
// this crashes!</DIV>
<DIV> </DIV>
<DIV> CORBA::String_var lRet =3D=20
inString; // deep=20
copy</DIV>
<DIV> </DIV>
<DIV> //return lRet; =20
// incorrect - this causes a =
release of=20
the returned object's memory <BR> return =
lRet._retn(); =20
// correct way - free is not called<BR>}<BR></DIV>
<DIV>I've tried using:</DIV>
<DIV>
<DIV> CORBA::String_var lRet =3D=20
CORBA::string_dup(inString);</DIV>
<DIV>with the same result.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I've also tried :</DIV>
<DIV>
<DIV>void Echo_i::echoString(const char* inString)<BR>{</DIV>
<DIV> // do nothing<BR>}<BR></DIV>
<DIV>and this has the same problem, so it doesn't appear to be anything =
to dow=20
ith my string handling...</DIV>
<DIV> </DIV>
<DIV>It seems whenever I use a string as an in, the server has this =
problem.=20
I've also tried specifying the string as an inout and I get the same=20
result.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I have implemented the following using Orbacus and it works =
fine:</DIV>
<DIV> </DIV>
<DIV>char* Hello_impl::echo(const char* pInString)<BR>// echos the sent=20
string<BR>{<BR> // works fine<BR> =20
CORBA_String_var lRet =3D pInString;<BR> return=20
lRet._retn();</DIV>
<DIV>}<BR></DIV>
<DIV> </DIV>
<DIV>For such a simple task, this is frustating me somewhat. </DIV>
<DIV>I have managed to send long's as in's without any problems, and I =
have=20
strings as returns, without any problems - it's just when a string is =
passed to=20
a function.</DIV>
<DIV>If anyone can assist, I'd be very grateful.</DIV>
<DIV> </DIV>
<DIV>I'm using omniOrb 3.04 on a Windows NT4 platform.</DIV>
<DIV> </DIV>
<DIV>Thank you</DIV>
<DIV> </DIV>
<DIV>David</DIV>
<DIV>--------------------------------------------------------------------=
--------------------------------<BR>David=20
Bellette  =
; =
=20
<BR>Senior Software Engineer</DIV>
<DIV>NEC Business Solutions Pty. Ltd.<BR>Australia</DIV>
<DIV>Email : <A=20
href=3D"mailto:david.bellette@nec.com.au">david.bellette@nec.com.au</A><B=
R>-----------------------------------------------------------------------=
-----------------------------</DIV></DIV></DIV></BODY></HTML>
------=_NextPart_000_0043_01C17E79.32A03FB0--