gmio_amf: make z_stream alloc/free functions parametrizable

This commit is contained in:
Hugues Delorme 2017-01-26 17:42:12 +01:00
parent e7a36b4a60
commit 1b1b2f03ea
2 changed files with 17 additions and 0 deletions

View File

@ -898,6 +898,9 @@ int gmio_amf_write(
mblock_halfsize,
NULL);
context.z_crc32 = gmio_zlib_crc32_initial();
context.z_stream.zalloc = opts->z_compress_options.func_alloc;
context.z_stream.zfree = opts->z_compress_options.func_free;
context.z_stream.opaque = opts->z_compress_options.opaque;
context.error =
gmio_zlib_compress_init(
&context.z_stream, &opts->z_compress_options);

View File

@ -81,6 +81,20 @@ struct gmio_zlib_compress_options
* \c 1 uses minimum memory but is slow and reduces compression ratio
* \c 9 uses maximum memory for optimal speed */
uint8_t memory_usage;
/*! Optional pointer to a function used to allocate the internal state
* within \c z_stream structure.
* \sa z_stream::zalloc */
void* (*func_alloc)(void* opaque, unsigned int items, unsigned int size);
/*! Optional pointer to a function used to free the internal state within
* \c z_stream structure.
* \sa z_stream::zfree */
void (*func_free)(void* opaque, void* address);
/*! Optional private data object passed to func_alloc and func_free.
* \sa z_stream::opaque */
void* opaque;
};
#endif /* GMIO_ZLIB_COMPRESS_H */