Mercurial > hg > dmlib
changeset 1050:e4f60c944a2d
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 18:31:29 +0200 |
parents | 771e03bf9fcd |
children | f2f4994c2f17 |
files | src/dmres.c |
diffstat | 1 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmres.c Sun Mar 01 18:16:10 2015 +0200 +++ b/src/dmres.c Sun Mar 01 18:31:29 2015 +0200 @@ -334,7 +334,7 @@ static int dm_pack_decompress(DMResource *handle, DMPackEntry *node) { - int res = DMERR_OK, cres, cdataLeft; + int ret = DMERR_OK, zret, cdataLeft; Uint8 * cbuffer = NULL; z_stream zstr; BOOL zinit = FALSE; @@ -342,7 +342,7 @@ // Allocate a structures and buffers if ((cbuffer = dmMalloc(DMRES_TMPBUF_SIZE)) == NULL) { - res = DMERR_MALLOC; + ret = DMERR_MALLOC; goto out; } @@ -352,16 +352,16 @@ zstr.avail_out = handle->rawSize; cdataLeft = node->length; - if (inflateInit(&zstr) != Z_OK) + if ((zret = inflateInit(&zstr)) != Z_OK) { - res = dmErrorDBG(DMERR_INIT_FAIL, + ret = dmErrorDBG(DMERR_INIT_FAIL, "Could not initialize zlib stream decompression.\n"); goto out; } zinit = TRUE; // Uncompress the data - while (cdataLeft > 0 && zstr.avail_out > 0 && cres == Z_OK) + while (cdataLeft > 0 && zstr.avail_out > 0 && zret == Z_OK) { zstr.avail_in = fread( cbuffer, sizeof(Uint8), @@ -370,7 +370,7 @@ cdataLeft -= zstr.avail_in; zstr.next_in = cbuffer; - cres = inflate(&zstr, Z_FULL_FLUSH); + zret = inflate(&zstr, Z_FULL_FLUSH); } @@ -380,7 +380,7 @@ inflateEnd(&zstr); dmFree(cbuffer); - return res; + return ret; } #else @@ -405,7 +405,19 @@ goto out; } + // XXX TEMP DEBUG + size_t n, off; + for (off = 0; off < 400;) { + for (n = 0; n < 16; n++) + printf("%02x ", inBuf[off + n]); + + printf(" | "); + for (n = 0; n < 16; n++) + printf("%c", isprint(inBuf[off + n]) ? inBuf[off + n] : '.'); + + printf("\n"); + off += n; } // Initialize decompression structures