Re: [PATCH v12 11/13] bisect--helper: `bisect_next_check` & bisect_voc shell function in C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 12, 2016, 18:11 UTC
- Message-ID
- <xmqq1t1tyi0z.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <010201567675ae68-15d79b9a-83fc-44ee-8607-07c2d0191c59-000000@eu-west-1.amazonses.com>
Pranit Bauva <pranit.bauva@gmail.com> writes:
Show 9 quoted lines
> +static char *bisect_voc(char *revision_type)
> +{
> + if (!strcmp(revision_type, "bad"))
> + return "bad|new";
> + if (!strcmp(revision_type, "good"))
> + return "good|old";
> +
> + return NULL;
> +}I think you can return "const char *" from the above function. Then you do not have to do xstrdup() on the return values to store in bad_syn and good_syn, and you do not have to free(3) them.
Show 6 quoted lines
> +static int bisect_next_check(const struct bisect_terms *terms,
> + const char *current_term)
> +{
> + ....
> + fprintf(stderr, N_("Warning: bisecting only with a %s commit\n"),
> + terms->term_bad.buf);Hmph, is this N_() and not _()?
Show 7 quoted lines
> + ....
> + }
> + bad_syn = xstrdup(bisect_voc("bad"));
> + good_syn = xstrdup(bisect_voc("good"));
> + ....
> + free(bad_syn);
> + free(good_syn);