From: "René Scharfe" <l.s.r@web.de>
To: Stefan Beller <sbeller@google.com>
Cc: avarab@gmail.com, git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH 2/2] builtin/blame: highlight recently changed lines
Date: Sat, 9 Jun 2018 13:26:53 +0200 [thread overview]
Message-ID: <737e4f2e-9896-0119-2c43-655ac29fe018@web.de> (raw)
In-Reply-To: <20180417213049.118995-2-sbeller@google.com>
Am 17.04.2018 um 23:30 schrieb Stefan Beller:
> +static void parse_color_fields(const char *s)
> +{
> + struct string_list l = STRING_LIST_INIT_DUP;
> + struct string_list_item *item;
> + enum { EXPECT_DATE, EXPECT_COLOR } next = EXPECT_COLOR;
> +
> + colorfield_nr = 0;
> +
> + /* Ideally this would be stripped and split at the same time? */
Why? Both approxidate() and color_parse() handle spaces.
> + string_list_split(&l, s, ',', -1);
> + ALLOC_GROW(colorfield, colorfield_nr + 1, colorfield_alloc);
> +
> + for_each_string_list_item(item, &l) {
> + switch (next) {
> + case EXPECT_DATE:
> + colorfield[colorfield_nr].hop = approxidate(item->string);
> + next = EXPECT_COLOR;
> + colorfield_nr++;
> + ALLOC_GROW(colorfield, colorfield_nr + 1, colorfield_alloc);
> + break;
> + case EXPECT_COLOR:
> + if (color_parse(item->string, colorfield[colorfield_nr].col))
> + die(_("expecting a color: %s"), item->string);
> + next = EXPECT_DATE;
> + break;
> + }
> + }
> +
> + if (next == EXPECT_COLOR)
> + die (_("must end with a color"));
> +
> + colorfield[colorfield_nr].hop = TIME_MAX;
> +}
This adds a minor memory leak; fix below.
-- >8 --
Subject: [PATCH] blame: release string_list after use in parse_color_fields()
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
builtin/blame.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/builtin/blame.c b/builtin/blame.c
index 4202584f97..3295718841 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -411,6 +411,7 @@ static void parse_color_fields(const char *s)
die (_("must end with a color"));
colorfield[colorfield_nr].hop = TIME_MAX;
+ string_list_clear(&l, 0);
}
static void setup_default_color_by_age(void)
--
2.17.1
next prev parent reply other threads:[~2018-06-09 11:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-16 22:09 [PATCH 0/2] blame: color line by commit Stefan Beller
2018-04-16 22:09 ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Stefan Beller
2018-04-17 3:17 ` Junio C Hamano
2018-04-17 19:04 ` Stefan Beller
2018-04-16 22:09 ` [PATCH 2/2] builtin/blame: highlight recently changed lines Stefan Beller
2018-04-17 3:23 ` Junio C Hamano
2018-04-17 3:29 ` Junio C Hamano
2018-04-17 19:31 ` Stefan Beller
2018-04-17 19:35 ` Stefan Beller
2018-04-17 21:30 ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Stefan Beller
2018-04-17 21:30 ` [PATCH 2/2] builtin/blame: highlight recently changed lines Stefan Beller
2018-04-17 21:54 ` Eric Sunshine
2018-04-18 0:39 ` Junio C Hamano
2018-06-09 11:26 ` René Scharfe [this message]
2018-06-11 23:56 ` Stefan Beller
2018-06-14 17:37 ` Junio C Hamano
2018-04-18 0:34 ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Junio C Hamano
2018-04-18 0:12 ` [PATCH 2/2] builtin/blame: highlight recently changed lines Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=737e4f2e-9896-0119-2c43-655ac29fe018@web.de \
--to=l.s.r@web.de \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).