Re: [PATCH 08/10] Introduce commit_list_append() in commit.c

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

 



Miklos Vajna <vmiklos@xxxxxxxxxxxxxx> writes:

> This is like commit_list_insert() but it appends the new commit to the
> end of the list, rather than insert to the start of it.
>
> Signed-off-by: Miklos Vajna <vmiklos@xxxxxxxxxxxxxx>
> ---
>  commit.c |   19 +++++++++++++++++++
>  commit.h |    1 +
>  2 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/commit.c b/commit.c
> index b45ec9b..6ba5acb 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -331,6 +331,25 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
>  	return new_list;
>  }
>  
> +struct commit_list *commit_list_append(struct commit *item,
> +	struct commit_list **list_p)
> +{
> +	struct commit_list *i, *prev = NULL, *list = *list_p;
> +	struct commit_list *new_list = xmalloc(sizeof(struct commit_list));
> +
> +	new_list->item = item;
> +	new_list->next = NULL;
> +
> +	if (!list)
> +		*list_p = new_list;
> +	else {
> +		for (i = list; i; i = i->next)
> +			prev = i;
> +		prev->next = new_list;
> +	}
> +	return list;
> +}

Do you have a caller of this function that keeps a pointer to commit_list
that needs to be appended at the tail or inserted at the beginning
depending on the phase of the moon, or does the caller always append to
that list?

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

  Powered by Linux