[PATCH 0/3] ref-filter: add a ref_sorting_release()

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

 



A follow-up to
https://lore.kernel.org/git/RFC-cover-v2-0.4-00000000000-20211020T131627Z-avarab@xxxxxxxxx/;

Junio: Hopefully this addresses the things you noted, thank[s| you]!
:)

I ejected your patch from this iteration, if you'd like to build on
top of it it should address the build failures in "seen" when combined
with your patch.

Ævar Arnfjörð Bjarmason (3):
  tag: use a "goto cleanup" pattern, leak less memory
  ref-filter API user: add and use a ref_sorting_release()
  branch: use ref_sorting_release()

 builtin/branch.c       |  8 +++++---
 builtin/for-each-ref.c |  2 +-
 builtin/tag.c          | 29 +++++++++++++++++------------
 ref-filter.c           |  9 +++++++++
 ref-filter.h           |  2 ++
 5 files changed, 34 insertions(+), 16 deletions(-)

Range-diff:
1:  fc776c3f1cd ! 1:  8ccd07abf86 tag: use a "goto cleanup" pattern, leak less memory
    @@ Metadata
      ## Commit message ##
         tag: use a "goto cleanup" pattern, leak less memory
     
    -    Change cmd_tag() to free its "struct string_list"'s instead of using
    -    an UNLEAK() pattern. This changes code added in 886e1084d78 (builtin/:
    +    Change cmd_tag() to free its "struct strbuf"'s instead of using an
    +    UNLEAK() pattern. This changes code added in 886e1084d78 (builtin/:
         add UNLEAKs, 2017-10-01).
     
    -    As shown in the context of the deceleration of the "struct
    +    As shown in the context of the declaration of the "struct
         msg_arg" (which I'm changing to use a designated initializer while at
         it, and to show the context in this change), that struct is just a
         thin wrapper around an int and "struct strbuf".
2:  0ae71c19ab7 ! 2:  07062ca276a ref-filter API user: add and use a ref_sorting_release()
    @@ ref-filter.c: int parse_opt_ref_sorting(const struct option *opt, const char *ar
      
     +void ref_sorting_release(struct ref_sorting *sorting)
     +{
    -+	struct ref_sorting *next = sorting->next;
    -+	if (next)
    -+	       ref_sorting_release(next);
    -+	free(sorting);
    ++	while (sorting) {
    ++		struct ref_sorting *next = sorting->next;
    ++		free(sorting);
    ++		sorting = next;
    ++	}
     +}
     +
      int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
3:  7abbbe4468c < -:  ----------- for-each-ref: delay parsing of --sort=<atom> options
4:  f7d87aea384 ! 3:  c8e8bc46ac4 branch: use ref_sorting_release()
    @@ Commit message
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
     
      ## builtin/branch.c ##
    -@@ builtin/branch.c: static const char *color_branch_slots[] = {
    - 	[BRANCH_COLOR_WORKTREE] = "worktree",
    - };
    - 
    --static struct string_list output = STRING_LIST_INIT_DUP;
    - static unsigned int colopts;
    - 
    - define_list_config_array(color_branch_slots);
     @@ builtin/branch.c: static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
      	return strbuf_detach(&fmt, NULL);
      }
    @@ builtin/branch.c: static void print_ref_list(struct ref_filter *filter, struct r
      		} else {
      			fwrite(out.buf, 1, out.len, stdout);
      			putchar('\n');
    -@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
    - 	enum branch_track track;
    - 	struct ref_filter filter;
    - 	int icase = 0;
    --	static struct ref_sorting *sorting;
    - 	struct string_list sorting_options = STRING_LIST_INIT_DUP;
    - 	struct ref_format format = REF_FORMAT_INIT;
    - 
    -@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
    - 		print_current_branch_name();
    - 		return 0;
    - 	} else if (list) {
    -+		struct ref_sorting *sorting;
    -+		static struct string_list output = STRING_LIST_INIT_DUP;
    -+
    - 		/*  git branch --list also shows HEAD when it is detached */
    - 		if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
    - 			filter.kind |= FILTER_REFS_DETACHED_HEAD;
     @@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
      		ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
      		ref_sorting_set_sort_flags_all(
-- 
2.33.1.1338.g20da966911a




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux