From: Jaroslav Kysela Date: Fri, 23 Jan 2015 20:30:23 +0000 (+0100) Subject: filebundle: do not use extra input buffer X-Git-Tag: v4.1~434 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3feccf34b5e926836774832df104fbb59b471326;p=thirdparty%2Ftvheadend.git filebundle: do not use extra input buffer --- diff --git a/src/filebundle.c b/src/filebundle.c index a69f0bb88..aefe29eb7 100644 --- a/src/filebundle.c +++ b/src/filebundle.c @@ -24,6 +24,7 @@ #include #include #if ENABLE_ZLIB +#define ZLIB_CONST 1 #include #endif #include @@ -78,18 +79,16 @@ static uint8_t *_fb_inflate ( const uint8_t *data, size_t size, size_t orig ) { int err; z_stream zstr; - uint8_t *bufin, *bufout; + uint8_t *bufout; /* Setup buffers */ - bufin = malloc(size); bufout = malloc(orig); - memcpy(bufin, data, size); /* Setup zlib */ memset(&zstr, 0, sizeof(zstr)); inflateInit2(&zstr, 31); zstr.avail_in = size; - zstr.next_in = bufin; + zstr.next_in = data; zstr.avail_out = orig; zstr.next_out = bufout; @@ -99,7 +98,6 @@ static uint8_t *_fb_inflate ( const uint8_t *data, size_t size, size_t orig ) free(bufout); bufout = NULL; } - free(bufin); inflateEnd(&zstr); return bufout; @@ -111,18 +109,16 @@ static uint8_t *_fb_deflate ( const uint8_t *data, size_t orig, size_t *size ) { int err; z_stream zstr; - uint8_t *bufin, *bufout; + uint8_t *bufout; /* Setup buffers */ - bufin = malloc(orig); bufout = malloc(orig); - memcpy(bufin, data, orig); /* Setup zlib */ memset(&zstr, 0, sizeof(zstr)); err = deflateInit2(&zstr, 9, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY); zstr.avail_in = orig; - zstr.next_in = bufin; + zstr.next_in = data; zstr.avail_out = orig; zstr.next_out = bufout; @@ -147,7 +143,6 @@ static uint8_t *_fb_deflate ( const uint8_t *data, size_t orig, size_t *size ) } break; } - free(bufin); deflateEnd(&zstr); return bufout;