common flatdevtree code

Hollis Blanchard hollisb at
Thu Sep 28 08:55:43 EST 2006

On Thu, 2006-09-28 at 08:32 +1000, Paul Mackerras wrote:
> Here's the latest version of my version of the flatdevtree code...
> I talked to David Gibson about this and he pointed out that there is a
> problem with using a void * to identify nodes (i.e. returned from
> ft_find_device and passed to ft_set_prop etc.).  The problem is that
> if we reallocate the space for the tree, then any void * handles that
> the user of the library has are then invalid.  Perhaps we have to use
> offsets from the beginning of the struct region instead - the offset
> for a node will be stable across changes of the node or any of its
> descendents, at least.

That is a non-obvious requirement and therefore a poor API.

Using offsets instead of pointers barely helps. All pointers break if
you need to realloc space for the tree. Almost all offsets break in the
exact same way (except for the ancestors of a particular node).

This may be a good reason to go back to the
	ft_set_prop("/node/property", value, len);
interface, instead of
	n = ft_find_node("/node");
	ft_set_prop(n, "property", value, len);

Hollis Blanchard
IBM Linux Technology Center

More information about the Linuxppc-dev mailing list