[augeas-devel] [PATCH] Write last created node in /augeas/tree/last_created for tree_create and tree_insert

David Lutterkort dlutter at redhat.com
Mon Aug 11 21:36:58 UTC 2008


On Mon, 2008-08-11 at 21:27 +0200, Raphaël Pinson wrote:


>              * Leave the prototype for tree_insert the way it is, but
>         change
>                its implementation to just call make_path, and move the
>         rest of
>                its body into a new function tree_insert_path that
>         takes a
>                struct path
> 
> I don't understand how that would change the problem. Eventually, the
> function that calculates the path to the newly created node has to
> know about the new tree. This tree cannot be easily exported so that
> means that this calculation is better done within tree_insert, and
> tree_insert has to return the result, so I don't see how a
> tree_insert_path function would change that. It seems much easier to
> me to call tree_insert with a struct path like you suggested before,
> and have struct path be generic.

What I am talking about is that right now tree_insert looks something
like

        tree_insert( ..., const char *path, ...) {
          struct path *p = make_path(path);
        
          .. lots of stuff that uses P but not PATH ...
        }
        
and to split that into

        tree_insert_path(..., struct path *p, ...) {
          .. lots of stuff that uses P but not PATH ...
          .. make sure P now refers to the new tree node ..
        }
        
        tree_insert(..., const char *path, ...) {
          struct path *p = make_path(path);
        
          result = tree_insert_path(..., p, ...);
        
          free_path(p);
        
          return result;
        }
        
        aug_insert(...) {
          struct path *p = make_path(path);
        
          result = tree_insert_path(..., p, ...);
        
          set_last_created_from_path(aug, p);
          free_path(p);
        
          return result;
        }

David




More information about the augeas-devel mailing list