src/hg/oneShot/freen/freen.c 1.91

1.91 2009/11/10 20:52:58 kent
Testing zlibFace.
Index: src/hg/oneShot/freen/freen.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/oneShot/freen/freen.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -b -B -U 1000000 -r1.90 -r1.91
--- src/hg/oneShot/freen/freen.c	10 Nov 2009 01:21:14 -0000	1.90
+++ src/hg/oneShot/freen/freen.c	10 Nov 2009 20:52:58 -0000	1.91
@@ -1,50 +1,48 @@
 /* freen - My Pet Freen. */
 #include "common.h"
-#include <zlib.h>
+#include "zlibFace.h"
 #include "memalloc.h"
 #include "dystring.h"
 #include "linefile.h"
 #include "hash.h"
 #include "obscure.h"
 
 
 static char const rcsid[] = "$Id$";
 
 void usage()
 {
 errAbort("freen - test some hairbrained thing.\n"
          "usage:  freen file\n");
 }
 
 
 void freen(char *input, char *output, char *uncompressed)
 /* Test some hair-brained thing. */
 {
 size_t uncompressedSize;
 char *uncompressedBuf;
 readInGulp(input, &uncompressedBuf, &uncompressedSize);
-uLongf maxSize = uncompressedSize * 1.001 + 13;
-uLongf compressedSize = maxSize;
-char *compressedBuf = needLargeMem(maxSize);
-int err = compress((Bytef*)compressedBuf, &compressedSize, (Bytef*)uncompressedBuf, uncompressedSize);
-printf("uncompressedSize %d, compressedSize %d, err %d\n", (int)uncompressedSize, (int)compressedSize, err);
+size_t compBufSize = zCompBufSize(uncompressedSize);
+char *compBuf = needLargeMem(compBufSize);
+size_t compressedSize = zCompress(uncompressedBuf, uncompressedSize, compBuf, compBufSize);
+printf("uncompressedSize %d, compressedSize %d\n", (int)uncompressedSize, (int)compressedSize);
 FILE *f = mustOpen(output, "wb");
-mustWrite(f, compressedBuf, compressedSize);
+mustWrite(f, compBuf, compressedSize);
 carefulClose(&f);
 f = mustOpen(uncompressed, "wb");
-uLongf uncSize = uncompressedSize;
 memset(uncompressedBuf, 0, uncompressedSize);
-err = uncompress((Bytef*)uncompressedBuf,  &uncSize, (Bytef*)compressedBuf, compressedSize);
-printf("uncompressedSize %d, err %d\n", (int)uncSize, err);
+size_t uncSize = zUncompress(compBuf, compressedSize, uncompressedBuf, uncompressedSize);
+printf("uncompressedSize %d\n", (int)uncSize);
 mustWrite(f, uncompressedBuf, uncSize);
 carefulClose(&f);
 }
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 if (argc != 4)
     usage();
 freen(argv[1], argv[2], argv[3]);
 return 0;
 }