You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Aaron Kaplan <ka...@xsoft.at> on 2001/03/20 19:36:51 UTC
C++ <-> C wrapper
Hello,
How would you tacle the problem of writing a Ansi C wrapper for
xerces-c(++)?
my application will run as apache module and link to other C programs, so
I need a C wrapper. It will also run forever, so mem leaks are a problem.
Currently I use new and delete on DOM_Node* ptrs to pass a reference to
the DOM_Node to the C caller. Is this the right way to wrap up the xerces
classes?
What happens is that the mem keeps growing and growing until the system
trashes.
I am currently using xerces 1.4.0
Let me give you an example wrapper function:
----- snip -----
typedef void * pTDomNode;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pTDomNode TDomGetNextSibling ( const pTDomNode p ) {
DOM_Node *s;
DOM_Node *n = (DOM_Node*)p;
if (NULL == p)
return NULL;
s = new DOM_Node(n->getNextSibling());
attach_gc(s); // attach it to my garbage collector which will
// delete it when delete parser is called
if (s->isNull())
return NULL;
else
return (pTDomNode)s;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------ snip -----
As far as I can see the _real_ question here is: will the real object
which is referenced by the DOM_Node class be deleted when I delete the
DOM_Node* ?
If not, how can I possibly wrap the C++ classes?
greetings,
aaron.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org