[augeas-devel] Label and value index of tree node

David Lutterkort lutter at redhat.com
Thu Oct 14 18:14:01 UTC 2010


On Mon, 2010-10-04 at 08:37 -0400, Francis Giraldeau wrote:
> Attached is a first draft of a patch for getting the node position,  
> namely indexes of label and value of a node in the input file. The  
> idea is to be able to highlight those in a UI.

Very nice idea ... is anybody working on a UI that uses this
information ?

I suspect there's another pair of positions you want ot keep track of:
the 'span' of the tree for interior nodes, i.e. the min(label_start,
value_start) and max(label_start, value_start) of all descendants of
that node. That would make it possible to highlight the 'region' of a
subtree, e.g. a line in /etc/hosts, when the user moves the mouse over
an interier tree node.

> A struct for indexes would be better, but I'm questioning where it  
> should be allocated and freed. I think that allocating it in the  
> get_subtree and free it in the tree destruction should be ok, but I'm  
> not sure if this is the "right" way to do it.

The one thing that makes me a little hesitant committing this right away
is that it increases the size of a tree node from 48 bytes to 64 bytes
(and possibly more) for every user of Augeas, even though most of them
won't make use of the position information.

Moving position information into a separate struct would lower the
impact somewhat for people that do not need position information, since
we'd just not allocate position information for them. Your strategy for
memory management sounds right, the position information should live
exactly as long as the struct tree.

My memory size concerns might not really matter - it's been a while
since I looked how much memory Augeas uses and for what. I know that the
regexp matcher is very memory hungry, but that memory is only used
transiently, whereas the tree generally sticks around for the lifetime
of a struct augeas.

David





More information about the augeas-devel mailing list