mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-06 10:19:06 +00:00
Create stream_compress_free and add it to file_archive_zlib
This commit is contained in:
parent
f264d3d29b
commit
d1ef6f032e
@ -434,13 +434,6 @@ bool file_archive_inflate_init(void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zlib_stream_deflate_free(void *data)
|
|
||||||
{
|
|
||||||
z_stream *ret = (z_stream*)data;
|
|
||||||
if (ret)
|
|
||||||
deflateEnd(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool file_archive_inflate_data_to_file_init(
|
bool file_archive_inflate_data_to_file_init(
|
||||||
zlib_file_handle_t *handle,
|
zlib_file_handle_t *handle,
|
||||||
const uint8_t *cdata, uint32_t csize, uint32_t size)
|
const uint8_t *cdata, uint32_t csize, uint32_t size)
|
||||||
|
@ -76,6 +76,13 @@ static void zlib_stream_decrement_total_out(void *data, unsigned subtraction)
|
|||||||
stream->total_out -= subtraction;
|
stream->total_out -= subtraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void zlib_stream_compress_free(void *data)
|
||||||
|
{
|
||||||
|
z_stream *ret = (z_stream*)data;
|
||||||
|
if (ret)
|
||||||
|
deflateEnd(ret);
|
||||||
|
}
|
||||||
|
|
||||||
const struct zlib_file_backend zlib_backend = {
|
const struct zlib_file_backend zlib_backend = {
|
||||||
zlib_stream_new,
|
zlib_stream_new,
|
||||||
zlib_stream_free,
|
zlib_stream_free,
|
||||||
@ -83,5 +90,6 @@ const struct zlib_file_backend zlib_backend = {
|
|||||||
zlib_stream_get_avail_out,
|
zlib_stream_get_avail_out,
|
||||||
zlib_stream_get_total_out,
|
zlib_stream_get_total_out,
|
||||||
zlib_stream_decrement_total_out,
|
zlib_stream_decrement_total_out,
|
||||||
|
zlib_stream_compress_free,
|
||||||
"zlib"
|
"zlib"
|
||||||
};
|
};
|
||||||
|
@ -339,11 +339,11 @@ static bool rpng_save_image(const char *path,
|
|||||||
|
|
||||||
if (zlib_deflate_data_to_file(stream) != 1)
|
if (zlib_deflate_data_to_file(stream) != 1)
|
||||||
{
|
{
|
||||||
zlib_stream_deflate_free(stream);
|
stream_backend->stream_compress_free(stream);
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
zlib_stream_deflate_free(stream);
|
stream_backend->stream_compress_free(stream);
|
||||||
|
|
||||||
memcpy(deflate_buf + 4, "IDAT", 4);
|
memcpy(deflate_buf + 4, "IDAT", 4);
|
||||||
dword_write_be(deflate_buf + 0, stream_backend->stream_get_total_out(stream));
|
dword_write_be(deflate_buf + 0, stream_backend->stream_get_total_out(stream));
|
||||||
|
@ -45,6 +45,7 @@ struct zlib_file_backend
|
|||||||
uint32_t (*stream_get_avail_out)(void*);
|
uint32_t (*stream_get_avail_out)(void*);
|
||||||
uint64_t (*stream_get_total_out)(void*);
|
uint64_t (*stream_get_total_out)(void*);
|
||||||
void (*stream_decrement_total_out)(void *, unsigned);
|
void (*stream_decrement_total_out)(void *, unsigned);
|
||||||
|
void (*stream_compress_free)(void *);
|
||||||
const char *ident;
|
const char *ident;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -162,8 +163,6 @@ void zlib_deflate_init(void *data, int level);
|
|||||||
|
|
||||||
int zlib_deflate_data_to_file(void *data);
|
int zlib_deflate_data_to_file(void *data);
|
||||||
|
|
||||||
void zlib_stream_deflate_free(void *data);
|
|
||||||
|
|
||||||
bool file_archive_inflate_init(void *data);
|
bool file_archive_inflate_init(void *data);
|
||||||
|
|
||||||
void zlib_set_stream(void *data,
|
void zlib_set_stream(void *data,
|
||||||
|
Loading…
Reference in New Issue
Block a user