Fixed buffered stream not being reset for reading after close.

Added ability to get buffer length for memory stream.
This commit is contained in:
Nathan Moinvaziri 2018-05-31 13:56:32 -07:00
parent 30e859be0b
commit 669f5a3086
3 changed files with 12 additions and 0 deletions

View File

@ -350,6 +350,11 @@ int32_t mz_stream_buffered_close(void *stream)
mz_stream_buffered_print(stream, "write efficency %.02f%%\n",
(buffered->writebuf_hits / ((float)buffered->writebuf_hits + buffered->writebuf_misses)) * 100);
buffered->readbuf_len = 0;
buffered->readbuf_pos = 0;
buffered->writebuf_len = 0;
buffered->writebuf_pos = 0;
return mz_stream_close(buffered->stream.base);
}

View File

@ -228,6 +228,12 @@ int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void *
return MZ_OK;
}
void mz_stream_mem_get_buffer_length(void *stream, int32_t *length)
{
mz_stream_mem *mem = (mz_stream_mem *)stream;
*length = mem->limit;
}
void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size)
{
mz_stream_mem *mem = (mz_stream_mem *)stream;

View File

@ -34,6 +34,7 @@ int32_t mz_stream_mem_error(void *stream);
void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size);
int32_t mz_stream_mem_get_buffer(void *stream, const void **buf);
int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf);
void mz_stream_mem_get_buffer_length(void *stream, int32_t *length);
void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size);
void* mz_stream_mem_create(void **stream);