As far as I know, you are correct in thinking that this code would work.
However, extreme caution should be taken over using code like this. I am
currently working on a project which uses similar reference counting,
and bugs in the this code are the hardest bugs we have had to track
down.

Surely though, if you want to create a c interface for the DOM, someone
has done this before, and found a better way...

John

Konstantin Kivi wrote:
> 
> On Wed, Apr 11, 2001 at 12:31:58PM -0400, [EMAIL PROTECTED] wrote:
> >
> > >Why can't I 'new' dom objects? Is this wrong practise
> > >unconditionally, or I only must be very careful?
> >
> > Wrong practice pretty much unconditionally, unless you're a parser or
> > otherwise need to access things in ways that the DOM APIs explicitly forbid
> > for normal applications. The factory methods may preform initializations or
> > have other side-effects that the c'tors don't, and public c'tors are _NOT_
> > part of the offical DOM API and will not be the same or supported in all
> > DOM implementations.
> >
> Again, I am not going to 'new' DOM objects here and there
> 
> What about the folloing example
> 
> extern "C" void * startDOM(some, parameters)
> {
>         .............
>         DOM_Document dom=domImpl.createDocument(...);
>         DOM_Document *pdom=new DOM_Document;
>         *pdom=dom; //I hope reference count=2  at this point
>                    // didn't read all the code yet
> 
>         return (void*)pdom;
>         // dom destroyed, RC=1
> }
> extern "C" domProcess(void *pvdom,some, thing ,to , do)
> {
>         DOM_Document pdom=(DOM_Document*)pvdom ; // RC still is 1
> 
>         do things as usual
> 
> }
> 
> extern "C" domFinish(void *pvdom)
> {
>         DOM_Document pdom=(DOM_Document*)pvdom ; // RC still is 1
> 
>         delete pdom ;// I hope this is the same as dom local variable
>                      // go out of scope; RC=0
> 
> }
> 
> What is wrong with this example?
> 
> --
> Sincerely Yours, Konstantin Kivi, Russia, [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
John Snelson, Software Engineer       DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to