[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    [PATCH 4/6] cgit_print_tree(): Free curr_rev after usage
From:       Jason () zx2c4 ! com (Jason A !  Donenfeld)
Date:       2013-03-05 1:36:46
Message-ID: CAHmME9pQpsK--4aLN55EZpam-Zg4qYY9C6xHsWY-GK=E1jEeRQ () mail ! gmail ! com
[Download RAW message or body]

On Mon, Mar 4, 2013 at 7:25 AM, Lukas Fleischer <cgit at cryptocrack.de> 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.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic