Re: [PATCH] pack-objects: use free()+xcalloc() instead of xrealloc()+memset()

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

 



Jeff King <peff@xxxxxxxx> writes:

> On Sun, Jun 01, 2014 at 01:07:21PM +0200, René Scharfe wrote:
>
>> Whenever the hash table becomes too small then its size is increased,
>> the original part (and the added space) is zerod out using memset(),
>> and the table is rebuilt from scratch.
>> 
>> Simplify this proceess by returning the old memory using free() and
>> allocating the new buffer using xcalloc(), which already clears the
>> buffer for us.  That way we avoid copying the old hash table contents
>> needlessly inside xrealloc().
>> 
>> While at it, use the first array member with sizeof instead of a
>> specific type.  The old code used uint32_t and int, while index is
>> actually an array of int32_t.  Their sizes are the same basically
>> everywhere, so it's not actually a problem, but the new code is
>> cleaner and doesn't have to be touched should the type be changed.
>> 
>> Signed-off-by: Rene Scharfe <l.s.r@xxxxxx>
>
> Looks good to me.
>
> BTW, the code does git-blame to Vicent's 2834bc2 (which I also worked
> on), but actually originated in 7a979d9 (Thin pack - create packfile
> with missing delta base., 2006-02-19). Not that it matters, but I was
> just surprised since the code you are changing did not seem familiar to
> me. I guess there was just too much refactoring during the code movement
> for git-blame to pass along the blame in this case.

Without -M, "too much refactoring" for git-blame may just be moving a
function to a different place in the same file.

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