Fwd: [omniORB] String in struct
Attila Czigány
atteeharp at gmail.com
Mon Apr 24 12:42:31 BST 2006
Hello,
I tried the "any" type, but I did not manage to get it work.
Thanks for the reply, I found my solution. (Exactly not me, a friend of
mine)
I write it down, maybe it is helpful for someone else, as I found more
questions about this.
My real problem was the glibc, wanted to free invalid pointer.
#idl
struct MyStruct{
string str;
long num;
}
interface MyData{
void get(out MyStruct s_data);
};
In a method I tried to to pass it to the out_arg as reference.
MyStruct myStruct;
...
s_data=&myStruct;
After this, the client got myStruct, it can read all the fields, but server
got
*** glibc detected *** free(): invalid pointer: 0x081443c4 ***
Maybe it wants to free s_data, but myStruct should not be freed.
The solution was, to allocate mem for s_data, and not just let it
initialized.
s_data=new MyStruct();
In this case I can copy the fields one by one.
Another, faster solution is to pass it immediatelly,
s_data=new MyStruct(myStruct);
And it seems to work pretty fine, and I do not need "any" or anything else.
Thanks, anyway,
Attila
On 4/24/06, Dominguez, Jose Luis wrote:
>
> I think that if you use char * instead of of string would work fine.
> to get char * from string, you can use c_str() function from string class.
>
> If you use type "any", i don't remember how it works, but you can use
> operator "<<" to insert and ">>" to extract.
> Some distributions have some errors with "any" types. But with strings
> there is no matter.
>
> value-> contains data
> type-> contains a number to identify the type of data it contains.
>
> Not quite sure of all this but hope it would be usefull.
> Jose
>
>
> ------------------------------
> *From:* omniorb-list-bounces at omniorb-support.com [mailto:
> omniorb-list-bounces at omniorb-support.com] *On Behalf Of *Attila Czigány
> *Sent:* domingo, 23 de abril de 2006 19:46
> *To:* omniorb-list at omniorb-support.com
> *Subject:* [omniORB] String in struct
>
> Hello,
> I am new to corba, tried a few things although. I would like to send a
> struct back and forth between the client and the server, that countains a
> string field, but unfortunatelly I had to realize, that it is not so easy.
> It works fine, when the struct contains just numbers.
> I found the "typecode" and "any" section in the documentation, but it is
> not too clear for me. Could anybody tell me, how can I send such struct? I
> use omniorb 4.0, and the c++ binding.
> Thanks, Attila
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060424/5c45f0a8/attachment.htm
More information about the omniORB-list
mailing list