[omniORB] How to use MyObject_var and MyObject_out
Jens Nissen
jens.nissen@gmx.net
Thu Feb 20 14:39:02 2003
I'm using omniOrb 3.05 on Win2K.
I have a simple Interface that roughly looks like this:
struct MyParameter
{
string message;
unsigned long id;
}
and I have a method
module MyModule
{
interface MyInterface
{
void GetData( in unsigned short x, out MyParameter y);
};
};
Now I want to write a client and a separate server!
How does the code for them have to look like?
I tried
// Client.CPP, myInterface is a MyInterface_var
void foo()
{
MyParameter_var p;
myInterface->GetData(1,p);
TRACE(p->message); // Message is still correct
return; // Crash here: Destruction of p->message violates heap
}
// Server.CPP, MyInterfaceClass derived from stub
void MyInterfaceClass::GetData(CORBA::UShort x, MyParameter_out y)
{
// x is correct
y = new MyParameter;
y->message = strdup((const char*)"Hallo");
y->id = 0;
}
But whatever I do, I get a heap violation inside the client.
I tried GetData(1,p.out()) on the client,
I tried to construct a var and return it with _retn() in the Server, both to
no avail.
Now there is one solution, but this looks more a less like a nasty hack and
cannot be real:
Change the client:
{ ...
p->message._ptr = 0;
return; // No crash: no wonder, but memory leak now?
}
How does the correct code look like?
Is there a CORBA sample somewhere on the WWW? All I find are copies of the
hello-sample, where a simple string is passed.
Kind regards,
Jens
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!