Re: [RFC/PATCHv8 08/10] fast-import: Proper notes tree manipulation using the notes API
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Nov 26, 2009, 19:33 UTC
- Message-ID
- <20091126193323.GU11919@spearce.org>
- In-Reply-To
- <200911261210.48138.johan@herland.net>
Johan Herland <johan@herland.net> wrote:
Show 5 quoted lines
> BTW, while we're on the topic, this whole code is only present because I > assume it's not possible to edit the fast-import tree structure _while_ > traversing it. Is this assumption correct, or are there ways to get > around maintaining a separate edit list that is applied to the tree > structure afterwards?
IIRC you can actually edit the tree while you are walking through it. You just have to watch out for the fact that a struct tree_content can be reallocated (and thus moved in memory) if the entry_capacity was too small for the new entry_count when inserting a new entry.
tree_content_set() handles this in its API by taking a struct tree_entry* rather than a struct tree_content*. This way if the tree has to expand during the set and gets reallocated we can return the new tree pointer to the caller through the struct tree_entry tree field.
-- Shawn.