# HG changeset patch # User Matti Hamalainen # Date 1425170421 -7200 # Node ID acda8cfc91195fa8f95026300273f62c0a00f3c7 # Parent aeafd6d444655087dc9222594ac7663681cf678c Also here. diff -r aeafd6d44465 -r acda8cfc9119 tools/packed.c --- a/tools/packed.c Sun Mar 01 02:39:18 2015 +0200 +++ b/tools/packed.c Sun Mar 01 02:40:21 2015 +0200 @@ -14,7 +14,7 @@ #define SET_MAX_FILES (4096) #define SET_DEFAULT_PACK "data.pak" - +#define SET_TMPBUF_SIZE (128 * 1024) enum { @@ -294,8 +294,8 @@ return DMERR_FOPEN; // Allocate temporary buffer - if ((inBuffer = (Uint8 *) dmMalloc(DPACK_TMPSIZE)) == NULL || - (outBuffer = (Uint8 *) dmMalloc(DPACK_TMPSIZE)) == NULL) + if ((inBuffer = (Uint8 *) dmMalloc(SET_TMPBUF_SIZE)) == NULL || + (outBuffer = (Uint8 *) dmMalloc(SET_TMPBUF_SIZE)) == NULL) { ret = DMERR_MALLOC; goto out; @@ -318,10 +318,10 @@ zres = Z_OK; while (!feof(inFile) && zres == Z_OK) { - zstr.avail_in = fread(inBuffer, sizeof(Uint8), DPACK_TMPSIZE, inFile); + zstr.avail_in = fread(inBuffer, sizeof(Uint8), SET_TMPBUF_SIZE, inFile); zstr.next_in = inBuffer; zstr.next_out = outBuffer; - zstr.avail_out = DPACK_TMPSIZE; + zstr.avail_out = SET_TMPBUF_SIZE; zstr.total_out = 0; zres = deflate(&zstr, Z_FULL_FLUSH); @@ -395,13 +395,13 @@ return -1; // Allocate temporary buffer - if ((inBuffer = (Uint8 *) dmMalloc(DPACK_TMPSIZE)) == NULL) + if ((inBuffer = (Uint8 *) dmMalloc(SET_TMPBUF_SIZE)) == NULL) { fclose(outFile); return DMERR_MALLOC; } - if ((outBuffer = (Uint8 *) dmMalloc(DPACK_TMPSIZE)) == NULL) + if ((outBuffer = (Uint8 *) dmMalloc(SET_TMPBUF_SIZE)) == NULL) { dmFree(inBuffer); fclose(outFile); @@ -426,8 +426,8 @@ ret = Z_OK; while (inDataLeft > 0 && ret == Z_OK) { - if (inDataLeft >= DPACK_TMPSIZE) - zstr.avail_in = fread(inBuffer, sizeof(Uint8), DPACK_TMPSIZE, pack->file); + if (inDataLeft >= SET_TMPBUF_SIZE) + zstr.avail_in = fread(inBuffer, sizeof(Uint8), SET_TMPBUF_SIZE, pack->file); else zstr.avail_in = fread(inBuffer, sizeof(Uint8), inDataLeft, pack->file); @@ -437,7 +437,7 @@ while (zstr.avail_in > 0 && ret == Z_OK) { zstr.next_out = outBuffer; - zstr.avail_out = DPACK_TMPSIZE; + zstr.avail_out = SET_TMPBUF_SIZE; zstr.total_out = 0; ret = inflate(&zstr, Z_FULL_FLUSH); if (zstr.total_out > 0)