Re: [PATCH v3 06/16] pathspec: copy and free owned memory
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 3, 2017, 12:06 UTC
- Message-ID
- <CACsJy8BnzE0Dis19RCddeFGhn-9Lm8R38NqN4T4qhHi1dRA8FQ@mail.gmail.com>
- In-Reply-To
- <1481670870-66754-7-git-send-email-bmwill@google.com>
On Wed, Dec 14, 2016 at 6:14 AM, Brandon Williams <bmwill@google.com> wrote:
Show 10 quoted lines
> void clear_pathspec(struct pathspec *pathspec)
> {
> + int i;
> +
> + for (i = 0; i < pathspec->nr; i++) {
> + free(pathspec->items[i].match);
> + free(pathspec->items[i].original);
> + }
> free(pathspec->items);
> pathspec->items = NULL;We should set pathspec->nr to zero so that calling this function again won't cause any harm.
> }
-- Duy