]> git.proxmox.com Git - libgit2.git/blobdiff - src/zstream.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / src / zstream.c
index fc8bfb86878d1a79916d709bdf432dd4fb54aac8..cb8b125ed5babf62b393359b92bf7bb65d30c61f 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <zlib.h>
 
-#include "buffer.h"
+#include "str.h"
 
 #define ZSTREAM_BUFFER_SIZE (1024 * 1024)
 #define ZSTREAM_BUFFER_MIN_EXTRA 8
@@ -77,6 +77,11 @@ bool git_zstream_done(git_zstream *zstream)
        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)
@@ -151,7 +156,7 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
        }
 
        /* 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;
@@ -159,7 +164,7 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
        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;
@@ -173,7 +178,7 @@ static int zstream_buf(git_buf *out, const void *in, size_t in_len, git_zstream_
        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;
@@ -194,12 +199,12 @@ done:
        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);
 }