Questions about memory management in CORBA
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rong_Lin
Posted On:   Tuesday, November 2, 2004 12:35 AM

Hello, I have met some questions in my work. First,define a struct with idl: struct A{ string B; } Then compile it and map it to C++: struct A{ char * B; } In my code I declare a variable X. A_var is used for automatic memory managerment: A_var X = new A; ... X->B = CORBA::string_dup("123"); ... Questions are as follows: 1.In practice,I found X->B was allocated space while A was declared.But what is the size of the space?How can CORBA decide the size? 2.If X->B is assigned a string value before ,memory reallocating will take place when string_dup() is called.Namely,after &qu   More>>

Hello,

I have met some questions in my work.

First,define a struct with idl:
struct A{
string B;
}

Then compile it and map it to C++:
struct A{
char * B;
}

In my code I declare a variable X. A_var is used for automatic memory
managerment:

A_var X = new A;
...
X->B = CORBA::string_dup("123");
...

Questions are as follows:
1.In practice,I found X->B was allocated space while A was declared.But what is the size of the space?How can CORBA decide the size?
2.If X->B is assigned a string value before ,memory reallocating will take place when string_dup() is called.Namely,after "X->B = CORBA::string_dup("123");",B is pointed to a new address.So I have to release the memory first allocated by myself to prevent memory leaking. If X->B is NOT assigned a string value before string_dup is called,will memory leaking occured??

Looking forwards to replies.

   <<Less
About | Sitemap | Contact