From: Junio C Hamano Date: Thu, 29 Sep 2011 22:06:03 GMT Subject: Re: [PATCH] refs: Use binary search to lookup refs faster Message-ID: <7vvcsbqa0k.fsf@alter.siamese.dyndns.org> In-Reply-To: <20110929041811.5363.33396.julian@quantumfyre.co.uk> Julian Phillips writes: > +static void add_ref(const char *name, const unsigned char *sha1, > + int flag, struct ref_array *refs, > + struct ref_entry **new_entry) > { > int len; > - struct ref_list *entry; > + struct ref_entry *entry; > > /* Allocate it and add it in.. */ > len = strlen(name) + 1; > - entry = xmalloc(sizeof(struct ref_list) + len); > + entry = xmalloc(sizeof(struct ref) + len); This should be sizeof(struct ref_entry), no? There is another such misallocation in search_ref_array() where it prepares a temporary.