Re: [PATCH 02/15] commit: push commit_index update into alloc_commit_node

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

 



Jeff King <peff@xxxxxxxx> writes:

> This will make the alloc_report output a little uglier (it will say
> raw_commit), but I don't think anyone cares. And I wanted to make sure
> there wasn't an easy way to accidentally call the wrong alloc function
> that doesn't handle the index.

Thanks; I like this change.

>
>  alloc.c  | 12 ++++++++++--
>  commit.c |  2 --
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/alloc.c b/alloc.c
> index 38ff7e7..eb22a45 100644
> --- a/alloc.c
> +++ b/alloc.c
> @@ -47,10 +47,18 @@ union any_object {
>  
>  DEFINE_ALLOCATOR(blob, struct blob)
>  DEFINE_ALLOCATOR(tree, struct tree)
> -DEFINE_ALLOCATOR(commit, struct commit)
> +DEFINE_ALLOCATOR(raw_commit, struct commit)
>  DEFINE_ALLOCATOR(tag, struct tag)
>  DEFINE_ALLOCATOR(object, union any_object)
>  
> +void *alloc_commit_node(void)
> +{
> +	static int commit_count;
> +	struct commit *c = alloc_raw_commit_node();
> +	c->index = commit_count++;
> +	return c;
> +}
> +
>  static void report(const char *name, unsigned int count, size_t size)
>  {
>  	fprintf(stderr, "%10s: %8u (%"PRIuMAX" kB)\n",
> @@ -64,7 +72,7 @@ void alloc_report(void)
>  {
>  	REPORT(blob, struct blob);
>  	REPORT(tree, struct tree);
> -	REPORT(commit, struct commit);
> +	REPORT(raw_commit, struct commit);
>  	REPORT(tag, struct tag);
>  	REPORT(object, union any_object);
>  }
> diff --git a/commit.c b/commit.c
> index f479331..21957ee 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -17,7 +17,6 @@ static struct commit_extra_header *read_commit_extra_header_lines(const char *bu
>  int save_commit_buffer = 1;
>  
>  const char *commit_type = "commit";
> -static int commit_count;
>  
>  static struct commit *check_commit(struct object *obj,
>  				   const unsigned char *sha1,
> @@ -64,7 +63,6 @@ struct commit *lookup_commit(const unsigned char *sha1)
>  	struct object *obj = lookup_object(sha1);
>  	if (!obj) {
>  		struct commit *c = alloc_commit_node();
> -		c->index = commit_count++;
>  		return create_object(sha1, OBJ_COMMIT, c);
>  	}
>  	if (!obj->type)
--
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]