Re: [PATCH v2 09/12] attr: (re)introduce git_check_attr() and struct git_attr_check

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

 



On Mon, May 16, 2016 at 5:05 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> A common pattern to check N attributes for many paths is to
>
>  (1) prepare an array A of N git_attr_check_elem items;
>  (2) call git_attr() to intern the N attribute names and fill A;
>  (3) repeatedly call git_check_attrs() for path with N and A;
> [...snip...]
> Introduce "struct git_attr_check" that contains N, the number of
> attributes being sought, and A, the array that holds N
> git_attr_check_elem items, and a function git_check_attr() that
> takes a path P and this structure as its parameters.  This structure
> can later be extended to hold extra data necessary for optimization.
>
> Also, to make it easier to write the first two steps in common
> cases, introduce git_attr_check_initl() helper function, which takes
> a NULL-terminated list of attribute names and initialize this
> structure.
> [...snip...]
>
> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
> ---
> diff --git a/attr.c b/attr.c
> @@ -825,3 +825,37 @@ void git_attr_set_direction(enum git_attr_direction new, struct index_state *ist
> +struct git_attr_check *git_attr_check_initl(const char *one, ...)
> +{
> +       [...]
> +       check = xcalloc(1,
> +                       sizeof(*check) + cnt * sizeof(*(check->check)));
> +       check->check_nr = cnt;
> +       check->check = (struct git_attr_check_elem *)(check + 1);
> +       [...]
> +       return check;
> +}
> diff --git a/attr.h b/attr.h
> @@ -29,6 +29,15 @@ struct git_attr_check_elem {
> +struct git_attr_check {
> +       int check_nr;
> +       int check_alloc;

This field is unused, and git_attr_check_initl() neglects to
initialize it (if it is intended to be used in the future).

> +       struct git_attr_check_elem *check;
> +};
--
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]