Re: [PATCH 04/32] move do_compress() from pack-objects.c to pack-write.c

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

 



On Wed, Aug 25, 2010 at 9:25 AM, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
>> +unsigned long compress_object(void **pptr, unsigned long size)
>> +{
>> +     z_stream stream;
>> +     void *in, *out;
>> +     unsigned long maxsize;
>> +
>> +     memset(&stream, 0, sizeof(stream));
>> +     deflateInit(&stream, Z_DEFAULT_COMPRESSION);
>> +     maxsize = deflateBound(&stream, size);
>> +
>> +     in = *pptr;
>> +     out = xmalloc(maxsize);
>> +     *pptr = out;
>> +
>> +     stream.next_in = in;
>> +     stream.avail_in = size;
>> +     stream.next_out = out;
>> +     stream.avail_out = maxsize;
>> +     while (deflate(&stream, Z_FINISH) == Z_OK)
>> +             ; /* nothing */
>> +     deflateEnd(&stream);
>> +
>> +     return stream.total_out;
>> +}
>
> However, there is nothing particularly specialized to git objects
> about this.  e.g. deflate_it() from diff.c could use this.

Also archive-zip.c, fast-import.c, http-push.c and remote-curl.c have
very similar code. I'll see if I can reduce some code duplication.
-- 
Duy
--
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]