On Mon, Mar 4, 2013 at 7:25 AM, Lukas Fleischer <[email protected]> wrote:
>         if (path == NULL) {
>                 ls_tree(commit->tree->object.sha1, NULL, &walk_tree_ctx);
> +               free(walk_tree_ctx.curr_rev);
>                 return;
>         }
>
>         read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, 
> &walk_tree_ctx);
>         if (walk_tree_ctx.state == 1)
>                 ls_tail();
> +       free(walk_tree_ctx.curr_rev);
>  }

For clean-up code that needs to be repeated for different error paths,
I generally prefer to have a "goto cleanup;" line, in the style of the
kernel. This function is simple enough that it's not a huge deal, but
it can help avoid bugs in the future when different folks are
modifying the function.

_______________________________________________
cgit mailing list
[email protected]
http://hjemli.net/mailman/listinfo/cgit

Reply via email to