[orbitcpp-list] Change in memory management...
Status: Beta
Brought to you by:
philipd
|
From: Phil d. <ph...@us...> - 2000-03-17 08:58:23
|
... of String_mgr and variable length structs.
Consider a variable length struct with a string in it:
// IDL
struct VariableLengthStruct {
string foo;
};
The old mechanism defined the delete operator for the variable length
struct to call CORBA_free() which would deep-free the struct (and
therefore free the string). This meant that the String_mgr couldn't
release the string in its destructor otherwise the memory would be freed
twice.
The problem is that the CORBA C++ language mapping allows variable
length structs to be created on the stack (thus no new and delete
operator involved) which causes the string memory to be leaked with the
above String_mgr implementation.
I've fixed this by making operator delete call ORBit_free() rather than
CORBA_free(), which allows me to free the struct without deep-freeing
the string. The String_mgr() class now releases its own strings and all
is right with the world (I hope).
N.B. there is still a requirement for a String_mgr class, since corba
2.3 requires that string members be initialised to "" rather than NULL
(which is what String_var must initialise them to).
Cheers,
Phil.
|