Create zlib_inflate_init
This commit is contained in:
parent
33fca0e161
commit
32304af540
|
@ -292,20 +292,25 @@ static uint32_t read_le(const uint8_t *data, unsigned size)
|
|||
|
||||
void *zlib_stream_new(void)
|
||||
{
|
||||
z_stream *ret = (z_stream*)calloc(1, sizeof(z_stream));
|
||||
return (z_stream*)calloc(1, sizeof(z_stream));
|
||||
}
|
||||
|
||||
if (inflateInit2(ret, -MAX_WBITS) != Z_OK)
|
||||
return NULL;
|
||||
return ret;
|
||||
bool zlib_inflate_init(void *data)
|
||||
{
|
||||
z_stream *stream = (z_stream*)data;
|
||||
|
||||
if (!stream)
|
||||
return false;
|
||||
if (inflateInit2(stream, -MAX_WBITS) != Z_OK)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void zlib_stream_free(void *data)
|
||||
{
|
||||
z_stream *ret = (z_stream*)data;
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
inflateEnd(ret);
|
||||
if (ret)
|
||||
inflateEnd(ret);
|
||||
}
|
||||
|
||||
bool zlib_inflate_data_to_file_init(
|
||||
|
@ -319,6 +324,9 @@ bool zlib_inflate_data_to_file_init(
|
|||
|
||||
if (!(handle->stream = (z_stream*)zlib_stream_new()))
|
||||
goto error;
|
||||
|
||||
if (!(zlib_inflate_init(handle->stream)))
|
||||
goto error;
|
||||
|
||||
handle->data = (uint8_t*)malloc(size);
|
||||
|
||||
|
|
|
@ -643,14 +643,14 @@ bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
|||
rpng->process.inflate_buf_size = 0;
|
||||
rpng->process.inflate_buf = NULL;
|
||||
|
||||
if (inflateInit(&rpng->process.stream) != Z_OK)
|
||||
return false;
|
||||
|
||||
png_pass_geom(&rpng->ihdr, rpng->ihdr.width,
|
||||
rpng->ihdr.height, NULL, NULL, &rpng->process.inflate_buf_size);
|
||||
if (rpng->ihdr.interlace == 1) /* To be sure. */
|
||||
rpng->process.inflate_buf_size *= 2;
|
||||
|
||||
if (inflateInit(&rpng->process.stream) != Z_OK)
|
||||
return false;
|
||||
|
||||
rpng->process.inflate_buf = (uint8_t*)malloc(rpng->process.inflate_buf_size);
|
||||
if (!rpng->process.inflate_buf)
|
||||
return false;
|
||||
|
|
|
@ -117,5 +117,7 @@ void *zlib_stream_new(void);
|
|||
|
||||
void zlib_stream_free(void *data);
|
||||
|
||||
bool zlib_inflate_init(void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue