Commit 744192c1 authored by marko's avatar marko

branches/zip: Implement custom memory management for zlib.

Wrap ut_malloc() and ut_free() as page_zip_alloc() and page_zip_free().
parent c7200092
......@@ -471,6 +471,31 @@ page_zip_dir_encode(
ut_a(i + 2/* infimum and supremum */ == n_heap);
}
/**************************************************************************
Allocate memory for zlib. */
static
void*
page_zip_alloc(
/*===========*/
void* opaque __attribute__((unused)),
uInt items,
uInt size)
{
return(ut_malloc(items * size));
}
/**************************************************************************
Deallocate memory for zlib. */
static
void
page_zip_free(
/*==========*/
void* opaque __attribute__((unused)),
void* address)
{
return(ut_free(address));
}
/**************************************************************************
Compress a page. */
......@@ -546,8 +571,8 @@ page_zip_compress(
buf_end = buf + page_zip->size - PAGE_DATA;
/* Compress the data payload. */
c_stream.zalloc = (alloc_func) 0;
c_stream.zfree = (free_func) 0;
c_stream.zalloc = page_zip_alloc;
c_stream.zfree = page_zip_free;
c_stream.opaque = (voidpf) 0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
......@@ -1400,8 +1425,8 @@ page_zip_decompress(
memcpy(page + (PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES + 1),
supremum_extra_data, sizeof supremum_extra_data);
d_stream.zalloc = (alloc_func) 0;
d_stream.zfree = (free_func) 0;
d_stream.zalloc = page_zip_alloc;
d_stream.zfree = page_zip_free;
d_stream.opaque = (voidpf) 0;
if (UNIV_UNLIKELY(inflateInit(&d_stream) != Z_OK)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment