Skip to content

memory pointer ownership #41

@smdjeff

Description

@smdjeff

it wasn't clear from the documentation... but uzlib_compress() allocates memory for out.outbuf
uzlib_compress() -> literal() -> zlib_literal() -> outbits() -> sresize()

it's odd that the comp.hash_table is allocated for uzlib by the app, but that uzlib allocates comp.out.outbuf on its own. it'd be cleaner if it was one or the other party doing the allocs.

I'd suggest this be documented (via the author's self documenting style) with a simple change to example/tgzip.c

comp.out.outbuf = malloc(0);
...
uzlib_compress(&comp, source, len);
...
free(comp.out.outbuf);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions