[omniORB] CORBA::string_dup / CORBA::String_var::string dup, (BUG ?)
Martin Trappel
tm5@gmx.at
Wed, 29 Aug 2001 15:48:59 +0200 (MEST)
Hello,
I've encountered a strange thing while accidently using
CORBA::String_var::string_dup instead of CORBA::string_dup.
[ System: WinNT4.0 sp6 / MSVC++ 5 sp3 ]
This code I used: (its just a test thingii)
----------
//IDL:
interface Echo {
string echoString(in string i, inout string io, out string o);
...
//C++ Impl Side:
char* Echo_impl::echoString(const char* i, char*& io, CORBA::String_out o)
{
...
io = CORBA::String_var::string_dup(i);
...
}
// C++ Client Side:
... CORBA::String_var inout = CORBA::String_var::string_dup("My inout");
...
CORBA::String_var retval;
...
retval = obj->echoString(in.in(), inout.inout(), out.out());
----------
This got me an debug assertion failure on the client side, when the inout
value that I passed to omniORB was deleted (before it should be assigned to the
value set in the server)
The solution was simple, I just substituted the String_var::string_dup with
CORBA::string_dup.
I looked at the code of these two methods and they are slightly different,
so it may be that the String_var::string_dup has a bug - or this whole thing
is intentional - but I thought I may point this out.
mfG, Trappel Martin
----- CORBA::string_dup -----
char*
CORBA::string_dup(const char* p)
{
if (p) {
char* q = omni::allocString(strlen(p));
if (q) {
strcpy(q,p);
return q;
}
}
return 0;
}
---- String_var::string_dup -----
static inline char* string_dup(const char* p) {
char* r = omni::allocString(strlen(p));
strcpy(r, p);
return r;
}
-----
--
******** Trappel Martin
country: Austria
e-mail: tm5@gmx.at
ICQ: 38158395
company: www.robotech.at
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net