Mercurial > hg > dmlib
changeset 1075:97ccd6d972ff
Comments, cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 02 Mar 2015 04:17:30 +0200 |
parents | e98bc627ad08 |
children | 21b0aedb7b5c |
files | src/dmzlib.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmzlib.c Mon Mar 02 04:13:56 2015 +0200 +++ b/src/dmzlib.c Mon Mar 02 04:17:30 2015 +0200 @@ -325,7 +325,7 @@ } else { - Uint8 *p; + Uint8 *ptr; int len, dist; if (z == 256) { @@ -352,21 +352,23 @@ "Bad Huffman block distance.\n"); } + // Check if output buffer needs to expand if (outBuffer + len > ctx->outBufferEnd) { if ((ret = dmZLibExpand(ctx, outBuffer, len)) != DMERR_OK) return ret; outBuffer = ctx->outBuffer; } - p = (Uint8 *) (outBuffer - dist); + + ptr = outBuffer - dist; if (dist == 1) { // run of one byte; common in images. - Uint8 v = *p; + Uint8 v = *ptr; do { *outBuffer++ = v; } while (--len); } else { - do { *outBuffer++ = *p++; } while (--len); + do { *outBuffer++ = *ptr++; } while (--len); } } } @@ -526,6 +528,7 @@ "Read past buffer, probably corrupt compressed data.\n"); } + // Check if output buffer needs to expand if (ctx->outBuffer + len > ctx->outBufferEnd && (ret = dmZLibExpand(ctx, ctx->outBuffer, len)) != DMERR_OK) { @@ -534,6 +537,7 @@ ret, dmErrorStr(ret)); } + // Copy uncompressed data memcpy(ctx->outBuffer, ctx->inBuffer, len); ctx->inBuffer += len; ctx->outBuffer += len;