diff options
| author | Hans Kristian Rosbach <hk-git@circlestorm.org> | 2024-04-16 22:20:03 +0200 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2024-05-28 16:35:13 +0200 |
| commit | 63e1d460aa02471c436e1bd0a1f9575cce52da5c (patch) | |
| tree | 5c1aaa2cb90eddc3818a5f733e76e34053070fc9 /test | |
| parent | 130055e8d11ce36fe55bccbc6fb854c9672b44c9 (diff) | |
| download | Project-Tick-63e1d460aa02471c436e1bd0a1f9575cce52da5c.tar.gz Project-Tick-63e1d460aa02471c436e1bd0a1f9575cce52da5c.zip | |
Rewrite inflate memory allocation.
Inflate used to allocate state during init, but window would be allocated
when/if needed and could be resized and that required a new free/alloc round.
- Now, we allocate state and a 32K window during init, allowing the latency cost
of allocs to be done during init instead of at one or more times later.
- Total memory allocation is about the same when requesting a 32K window, but
if now window or a smaller window was requested, then it is an increase.
- While doing alloc(), we now store pointer to corresponding free(), avoiding crashes
with applications that incorrectly set alloc/free pointers after running init function.
- After init has succeeded, inflate will no longer possibly fail due to a failing malloc.
Co-authored-by: Ilya Leoshkevich <iii@linux.ibm.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/infcover.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/test/infcover.c b/test/infcover.c index 6606d222a9..6a9999e0f0 100644 --- a/test/infcover.c +++ b/test/infcover.c @@ -319,9 +319,6 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int if (ret == Z_NEED_DICT) { ret = PREFIX(inflateSetDictionary)(&strm, in, 1); assert(ret == Z_DATA_ERROR); - mem_limit(&strm, 1); - ret = PREFIX(inflateSetDictionary)(&strm, out, 0); - assert(ret == Z_MEM_ERROR); mem_limit(&strm, 0); ((struct inflate_state *)strm.state)->mode = DICT; ret = PREFIX(inflateSetDictionary)(&strm, out, 0); @@ -418,10 +415,6 @@ static void cover_wrap(void) { strm.next_in = (void *)"\x63"; strm.avail_out = 1; strm.next_out = (void *)&ret; - mem_limit(&strm, 1); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); - ret = PREFIX(inflate)(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); - mem_limit(&strm, 0); memset(dict, 0, 257); ret = PREFIX(inflateSetDictionary)(&strm, dict, 257); assert(ret == Z_OK); |
