Re: [PATCH v4 02/10] ref-filter: make the 'color' use ref_formatting_state

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

 



On Fri, Jul 24, 2015 at 3:04 PM, Karthik Nayak <karthik.188@xxxxxxxxx> wrote:
> Make color which was considered as an atom, to use
> ref_formatting_state and act as a pseudo atom. This allows
> interchangeability between 'align' and 'color'.
>
> Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx>
> ---
> diff --git a/ref-filter.c b/ref-filter.c
> index 3c90ffc..fd13a23 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -663,7 +663,8 @@ static void populate_value(struct ref_formatting_state *state,
> -                       v->s = xstrdup(color);
> +                       state->color = xstrdup(color);
> +                       v->pseudo_atom = 1;
> @@ -1217,6 +1218,11 @@ void ref_array_sort(struct ref_sorting *sorting, struct ref_array *array)
> +       if (state->color) {
> +               strbuf_addstr(value, state->color);
> +               free((void *)state->color);
> +               state->color = NULL;
> +       }
> @@ -1326,7 +1333,8 @@ void show_ref_array_item(struct ref_array_item *info, const char *format, int qu
> -               resetv.s = color;
> +               resetv.s = "";
> +               state.color = xstrdup(color);
> diff --git a/ref-filter.h b/ref-filter.h
> index ea2d0e6..bacbb23 100644
> --- a/ref-filter.h
> +++ b/ref-filter.h
> @@ -31,6 +31,7 @@ struct ref_sorting {
>  struct ref_formatting_state {
>         unsigned int pad_to_right; /*pad atoms to the right*/
>         int quote_style;
> +       const char *color;
>  };

Should 'color' should be declared 'char *' rather than 'const char *'?
It's always assigned via xstrdup(), and if declared 'char *', you
wouldn't have to cast away the 'const' when freeing it.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]