# HG changeset patch # User Matti Hamalainen # Date 1425227489 -7200 # Node ID e4f60c944a2dff908382b6f4890991b1aa1d09f1 # Parent 771e03bf9fcd818d15e6059dd5a1b4ac5fba7ded Cleanups. diff -r 771e03bf9fcd -r e4f60c944a2d src/dmres.c --- 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