changeset 996:acda8cfc9119

Also here.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Mar 2015 02:40:21 +0200
parents aeafd6d44465
children cd0e0270e1ce
files tools/packed.c
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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)