Re: [gdome]question about internals



Hello Stefano,

On Thu, 2004-03-18 at 09:29, Stefano Borini wrote:
> I'm developing a fortran 77 binding to gdome2. You can find it at
> 
> http://members.ferrara.linux.it/munehiro/f77xml/
> 
> The problem is quite tricky.

indeed!!! I thought the times of max-6-chars-for-identifier languages
were over, but I was wrong :-(

> implementation store each reference to nodes, nodelists and so on in a cache, 
> and returns an integer that refers to the cache position.

aha

> Doing some experiment with gdome2 in C, i noted that even ref'ing, then 
> unref'ing and the ref'ing again the element, or accessing in different ways 
> (from its parent or its child), the pointer that is returned is always the 
> same. Is this consistence guaranteed by the DOM implementation of gdome, or 
> it's simply a consequence of the small example i'm running? I tried to browse 
> the sources, and as far as i understood the element is completely freed every 
> time the refcount fall to zero, then subsequents access to the same node can 
> return, in principle, a different memory pointer. If The refcount never fall 
> to zero, the node is always referred with the same pointer, regardless the 
> way used to obtain it.

you're right. At the risk of being obvious: as long as a Gdome2
structure for a node x stays in memory, no matter _how_ you access node
x, you'll get the same pointer to the same Gdome2 structure for x. If
you unref the structure and the ref counter gets to zero, the structure
is freed and the next time you ask for it it'll most likely have a
different address.

> last question: if i obtain a nodelist, when unref'ing it the referred nodes 
> are automatically unrefferred (refCount--) ?

yes, you don't have to worry about (neither you know) what the NodeList
refers.

HTH,
--luca





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]