[omniORB] C++ mapping of IDL struct

Sean Parker supinlick at yahoo.com
Tue Apr 17 08:18:02 BST 2007



Hello -

  I have a question about the "proper" way to return
structs from server methods. (I end up with a memory leak,
but the data gets through fine)

For example:

  <IDL code>
  struct MyStruct
  {
      long a;
      string b;
  };
  interface X
  {
      MyStruct doit();
  }
  <end IDL code>

Then in C++:

  <C++ code>

  MyStruct*
  X_impl::doit()
  {
      MyStruct* ms = new MyStruct();
      ms->a = 0;
      ms->b = ::CORBA::string_dup( "hello" );
      return ms;
  }

  <end C++ Code>


I suppose there are "preferred" ways to do this, so that's
what I'm asking, what's the preferred (or only) way to do
this w/o memory leaks? When using valgrind, I always have a
leak of both the string 'b' and the MyStruct allocation. Is
there a alloc_buf function I need to use, as in creating
sequences of structs? (I thought of always returning
sequences of size one, since I do sequences alot elsewhere
w/o leaks, but that seems klugy...)

  Any help appreciated - 
    Thanks and God Bless

      Sean  

P.S. I'm using oo 4;

P.P.S. the C++ mapping doc from OMG suggestes something
like a _rtrn() function, as an example for implementations
to do things, but not sure that omniORB has such a thing...


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the omniORB-list mailing list