Commit Graph

9 Commits

Author SHA1 Message Date
Edward Thomson
4aa664ae39 git_buf_grow_by: increase buf asize incrementally
Introduce `git_buf_grow_by` to incrementally increase the size of a
`git_buf`, performing an overflow calculation on the growth.
2015-02-12 22:54:47 -05:00
Edward Thomson
392702ee2c allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
2015-02-12 22:54:46 -05:00
Carlos Martín Nieto
c7f86efb13 zstream: grow based on used memory rather than allocated
When deflating data, we might need to grow the buffer. Currently we
add a guess on top of the currently-allocated buffer size.

When we re-use the buffer, it already has some memory allocated; adding
to that means that we always grow the buffer regardless of how much we
need to use.

Instead, increase on top of the currently-used size. This still leaves
us with the allocated size of the largest object we compress, but it's a
minor pain compared to unbounded growth.

This fixes #2285.
2014-04-26 18:04:43 +02:00
Russell Belfer
19459b1e29 Defer zstream NUL termination to end
And don't terminate if there isn't space for it (since it's binary
data, it's not worth a reallocation).
2014-01-30 10:23:35 -08:00
Russell Belfer
8606f33bea Expand zstream tests and fix off-by-one error 2014-01-30 10:00:00 -08:00
Russell Belfer
d9b04d78a3 Reorganize zstream API and fix wrap problems
There were some confusing issues mixing up the number of bytes
written to the zstream output buffer with the number of bytes
consumed from the zstream input.  This reorganizes the zstream
API and makes it easier to deflate an arbitrarily large input
while still using a fixed size output.
2014-01-30 09:59:59 -08:00
XTao
1cb5a81194 Fix write_object. 2014-01-26 22:26:53 +08:00
Edward Thomson
52a8a13072 Packbuilder contains its own zstream 2014-01-14 09:45:14 -08:00
Edward Thomson
c6f26b48e4 Refactor zlib for easier deflate streaming 2014-01-14 09:45:12 -08:00