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

Re: [augeas-devel] [PATCH] Add aug_rename to rename node labels without moving them in the tree.



Actually missed a memory leak earlier:

On Wed, 2012-08-01 at 10:54 +0200, Raphaël Pinson wrote:
> diff --git a/src/augeas.c b/src/augeas.c
> index 22ebd14..7ca081a 100644
> --- a/src/augeas.c
> +++ b/src/augeas.c
> @@ -1245,6 +1245,32 @@ int aug_mv(struct augeas *aug, const char *src, const char *dst) {
>      return ret;
>  }
>  
> +int aug_rename(struct augeas *aug, const char *src, const char *lbl) {
> +    struct pathx *s = NULL;
> +    struct tree *ts;
> +    int r, ret;
> +
> +    api_entry(aug);
> +
> +    ret = -1;
> +    s = pathx_aug_parse(aug, aug->origin, tree_root_ctx(aug), src, true);
> +    ERR_BAIL(aug);
> +
> +    r = find_one_node(s, &ts);
> +    if (r < 0)
> +        goto error;
> +
> +    ts->label = strdup(lbl);

You need to do a 'free(ts->label)' first before assigning to it. (We
don't have a utility function to parallel tree_set_value)

David



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