Andrew Buza
2008-08-26 06:16:49 UTC
I posted a thread about problems I was having using CORBA sequences
back in June ( http://www.omniorb-support.com/pipermail/omniorb-list/2008-June/029546.html
). Following Martin's suggestion, I double-checked my allocations, use
of _var types, etc., but was unable to find anything that (to my eyes)
was wrong. Coming back to that problem now, I have a sample typical of
where I'm having difficulty. I have the following (abridged) IDL:
struct Node
{
string kind;
string key;
};
typedef sequence<Node> NodeList;
interface Hierarchy
{
Node getRootNode();
NodeList getChildren(in Node n);
};
My client attempts to get a list of all nodes with kind == "Queue" like so:
{
std::list<std::string> queues;
//... get Hierarchy object reference...
Node_var root = hierarchy->getRootNode();
visit_node(hierarchy, root, queues);
}
void visit_node(Hierarchy_ptr hierarchy, Node const & node,
list<string> &queues)
{
if(strcmp(node.kind,"Queue") == 0)
{
queues.push_back(string(node.key));
}
NodeList_var children = hierarchy->getChildren(node);
CORBA::ULong nchildren = children->length();
for(CORBA::ULong c = 0; c < nchildren; c++)
{
Node const & node = children[c];
visit_node(hierarchy, node, queues);
}
}
When this is run I'll get a message indicating heap corruption and the
IDE (MSVC8.0) will break in the _CORBA_Sequence destructor.
Is the listing above correct, or is there something I'm not
understanding about memory management in CORBA?
back in June ( http://www.omniorb-support.com/pipermail/omniorb-list/2008-June/029546.html
). Following Martin's suggestion, I double-checked my allocations, use
of _var types, etc., but was unable to find anything that (to my eyes)
was wrong. Coming back to that problem now, I have a sample typical of
where I'm having difficulty. I have the following (abridged) IDL:
struct Node
{
string kind;
string key;
};
typedef sequence<Node> NodeList;
interface Hierarchy
{
Node getRootNode();
NodeList getChildren(in Node n);
};
My client attempts to get a list of all nodes with kind == "Queue" like so:
{
std::list<std::string> queues;
//... get Hierarchy object reference...
Node_var root = hierarchy->getRootNode();
visit_node(hierarchy, root, queues);
}
void visit_node(Hierarchy_ptr hierarchy, Node const & node,
list<string> &queues)
{
if(strcmp(node.kind,"Queue") == 0)
{
queues.push_back(string(node.key));
}
NodeList_var children = hierarchy->getChildren(node);
CORBA::ULong nchildren = children->length();
for(CORBA::ULong c = 0; c < nchildren; c++)
{
Node const & node = children[c];
visit_node(hierarchy, node, queues);
}
}
When this is run I'll get a message indicating heap corruption and the
IDE (MSVC8.0) will break in the _CORBA_Sequence destructor.
Is the listing above correct, or is there something I'm not
understanding about memory management in CORBA?