#include <zlib.h>
-#include "buffer.h"
+#include "str.h"
#define ZSTREAM_BUFFER_SIZE (1024 * 1024)
#define ZSTREAM_BUFFER_MIN_EXTRA 8
return (!zstream->in_len && zstream->zerr == Z_STREAM_END);
}
+bool git_zstream_eos(git_zstream *zstream)
+{
+ return zstream->zerr == Z_STREAM_END;
+}
+
size_t git_zstream_suggest_output_len(git_zstream *zstream)
{
if (zstream->in_len > ZSTREAM_BUFFER_SIZE)
}
/* either we finished the input or we did not flush the data */
- assert(zstream->in_len > 0 || zstream->flush == Z_FINISH);
+ GIT_ASSERT(zstream->in_len > 0 || zstream->flush == Z_FINISH);
/* set out_size to number of bytes actually written to output */
*out_len = *out_len - out_remain;
return 0;
}
-static int zstream_buf(git_buf *out, const void *in, size_t in_len, git_zstream_t type)
+static int zstream_buf(git_str *out, const void *in, size_t in_len, git_zstream_t type)
{
git_zstream zs = GIT_ZSTREAM_INIT;
int error = 0;
while (!git_zstream_done(&zs)) {
size_t step = git_zstream_suggest_output_len(&zs), written;
- if ((error = git_buf_grow_by(out, step)) < 0)
+ if ((error = git_str_grow_by(out, step)) < 0)
goto done;
written = out->asize - out->size;
return error;
}
-int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
+int git_zstream_deflatebuf(git_str *out, const void *in, size_t in_len)
{
return zstream_buf(out, in, in_len, GIT_ZSTREAM_DEFLATE);
}
-int git_zstream_inflatebuf(git_buf *out, const void *in, size_t in_len)
+int git_zstream_inflatebuf(git_str *out, const void *in, size_t in_len)
{
return zstream_buf(out, in, in_len, GIT_ZSTREAM_INFLATE);
}