[GRASS-SVN] r61424 - grass/branches/releasebranch_7_0/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 03:57:50 PDT 2014


Author: mmetz
Date: 2014-07-28 03:57:49 -0700 (Mon, 28 Jul 2014)
New Revision: 61424

Modified:
   grass/branches/releasebranch_7_0/lib/gis/flate.c
Log:
libgis: fix memory leak in G_zlib_compress(), comment on compression levels

Modified: grass/branches/releasebranch_7_0/lib/gis/flate.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/gis/flate.c	2014-07-28 10:56:33 UTC (rev 61423)
+++ grass/branches/releasebranch_7_0/lib/gis/flate.c	2014-07-28 10:57:49 UTC (rev 61424)
@@ -326,8 +326,11 @@
     c_stream.avail_out = buf_sz;
     c_stream.next_out = buf;
 
-    /* Initialize using default compression (usually 6) */
-    err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
+    /* Initialize */
+    /* Compression levels 0 - 9 */
+    /* zlib default: Z_DEFAULT_COMPRESSION (-1), equivalent to 6 
+     * as used here, 1 gives the best compromise between speed and compression */
+    err = deflateInit(&c_stream, 1);
 
     /* If there was an error initializing, return -1 */
     if (err != Z_OK) {
@@ -358,6 +361,7 @@
     nbytes = buf_sz - c_stream.avail_out;
     if (nbytes > dst_sz) {	/* Not enough room to copy output */
 	G_free(buf);
+	deflateEnd(&c_stream);
 	return -2;
     }
     /* Copy the data from buf to dst */



More information about the grass-commit mailing list