From: Joe E. <jen...@fl...> - 2002-05-30 15:06:28
|
Steve Ball <Ste...@zv...> wrote: > Joe English wrote: > > (Using strings with handle semantics is actually the safest > > thing to do in the presence of [dom::DOMImplementation destroy]. > > Using a custom Tcl_ObjType can lead to Tcl_Obj's with dangling > > pointers in their internal reps if you're not _extremely_ careful.) > > TclDOM/libxml2 defines a string handle for an object, as well as > an internal rep. I maintain a hash table of string reps, > so if the object loses its internal rep it can be retrieved > from the string rep. This strategy allows faster performance > when the internal rep is preserved, but is still reliable. > > I haven't fully resolved object destruction yet. That's where the trouble comes in -- if a node is deleted, then any TclDOM_NodeObj's which have _not_ lost their internal rep will contain dangling pointers to deleted nodes. One possibility: add a reference count to the internal xmlNode structure, and increment/decrement it in the TclDOM_NodeObjType's SetFromAnyProc/FreeInternalRepProc. Or maybe associate reference counts with the owner xmlDocument. > > Even if dom::c did use a custom Tcl_ObjType, there would still > > be a danger if multiple DOMImplementations are loaded into the > > same process. > > My assumption was that having multiple implementations > simultaneously loaded might be useful for some applications. > Is that an incorrect assumption? It doesn't seem to me that this will be needed very often. At the Tcl script level, one DOMImplementation should be as good as another modulo features supported in one but not in the other. --Joe English jen...@fl... |