Index: trunk/Ohana/src/libfits/extern/gzip.c
===================================================================
--- trunk/Ohana/src/libfits/extern/gzip.c	(revision 39399)
+++ trunk/Ohana/src/libfits/extern/gzip.c	(revision 39457)
@@ -122,5 +122,5 @@
 
   z_stream stream;
-  int i, err;
+  int err;
   
   stream.next_in = (Bytef*)source;
@@ -140,4 +140,5 @@
   if (EXTRA_VERBOSE) {
     fprintf (stderr, "inp cmp: ");
+    unsigned long int i;
     for (i = 0; i < sourceLen; i++) {
       fprintf (stderr, "0x%02hhx ", source[i]);
@@ -165,4 +166,5 @@
   if (EXTRA_VERBOSE) {
     fprintf (stderr, "out cmp: ");
+    unsigned long int i;
     for (i = 0; i < stream.total_out; i++) {
       fprintf (stderr, "0x%02hhx ", dest[i]);
@@ -182,5 +184,5 @@
 
   z_stream stream;
-  int i, err;
+  int err;
   
   stream.next_in = (Bytef*)source;
@@ -200,4 +202,5 @@
   if (EXTRA_VERBOSE) {
     fprintf (stderr, "inp unc: ");
+    unsigned long int i;
     for (i = 0; i < sourceLen; i++) {
       fprintf (stderr, "0x%02hhx ", source[i]);
@@ -226,4 +229,5 @@
   if (EXTRA_VERBOSE) {
     fprintf (stderr, "out unc: ");
+    unsigned long int i;
     for (i = 0; i < stream.total_out; i++) {
       fprintf (stderr, "0x%02hhx ", dest[i]);
Index: trunk/Ohana/src/libfits/header/F_write_H.c
===================================================================
--- trunk/Ohana/src/libfits/header/F_write_H.c	(revision 39399)
+++ trunk/Ohana/src/libfits/header/F_write_H.c	(revision 39457)
@@ -25,5 +25,5 @@
     myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
     myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
-    myAssert (myBlock->size >= header[0].datasize, "overflow");
+    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
   }
 # endif
Index: trunk/Ohana/src/libfits/include/gfits_compress.h
===================================================================
--- trunk/Ohana/src/libfits/include/gfits_compress.h	(revision 39457)
+++ trunk/Ohana/src/libfits/include/gfits_compress.h	(revision 39457)
@@ -0,0 +1,28 @@
+# include <zlib.h>
+
+/* functions defined in ricecomp.c */
+int fits_rcomp(int a[], int nx,	unsigned char *c, int clen, int nblock);
+int fits_rcomp_short(short a[], int nx, unsigned char *c, int clen, int nblock);
+int fits_rcomp_byte(char a[], int nx, unsigned char *c, int clen, int nblock);
+int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
+int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
+int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
+
+/* functions defined in fits_hcompress.c */
+# define LONGLONG long long
+int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
+int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
+
+/* functions defined in fits_hdeccompress.c */
+int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
+int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
+
+/* functions defined in pliocomp.c */
+int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
+int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
+
+/* functions defined in gzip.c */
+int gfits_gz_stripheader (unsigned char *data, int *ndata);
+int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
+int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
+
Index: trunk/Ohana/src/libfits/include/gfitsio.h
===================================================================
--- trunk/Ohana/src/libfits/include/gfitsio.h	(revision 39399)
+++ trunk/Ohana/src/libfits/include/gfitsio.h	(revision 39457)
@@ -193,23 +193,23 @@
 
 int     gfits_uncompress_image 	       PROTO((Header *header, Matrix *matrix, FTable *ftable));
-int     gfits_uncompress_data  	       PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize));
-int     gfits_distribute_data  	       PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
-
-int     gfits_compress_data  	       PROTO((char *zdata, int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, int Nraw, int raw_pixsize, int Nx, int Ny));
-int     gfits_compress_image 	       PROTO((Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype));
-int     gfits_collect_data   	       PROTO((Matrix *matrix, char *raw, int Nraw, int raw_pixsize, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
+int     gfits_uncompress_data  	       PROTO((char *zdata, unsigned long int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize));
+int     gfits_distribute_data  	       PROTO((Matrix *matrix, char *data, unsigned long int Ndata, int bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
+
+int     gfits_compress_data  	       PROTO((char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nraw, int raw_pixsize, int Nx, int Ny));
+int     gfits_compress_image 	       PROTO((Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype));
+int     gfits_collect_data   	       PROTO((Matrix *matrix, char *raw, unsigned long int Nraw, int raw_pixsize, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
 
 int     gfits_copy_keywords_compress   PROTO((Header *srchead, Header *tgthead));
 int     gfits_swap_raw   	       PROTO((Matrix *matrix));
 
-off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, int *ztile));
-int 	gfits_imtile_maxsize           PROTO((Matrix *matrix, int *ztile));
-int 	gfits_imtile_count             PROTO((Matrix *matrix, int *ztile, int *ntile));
+off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, unsigned long int *ztile));
+int 	gfits_imtile_maxsize           PROTO((Matrix *matrix, unsigned long int *ztile));
+int 	gfits_imtile_count             PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile));
 int 	gfits_imtile_start             PROTO((Matrix *matrix, int *otile));
-int 	gfits_imtile_next              PROTO((Matrix *matrix, int *ztile, int *ntile, int *otile));
+int 	gfits_imtile_next              PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile));
 
 int     gfits_extension_is_compressed_image  PROTO((Header *header));
 int     gfits_extension_is_compressed_table  PROTO((Header *header));
-int     gfits_byteswap_zdata   	        PROTO((char *zdata, int Nzdata, int pixsize));
+int     gfits_byteswap_zdata   	        PROTO((char *zdata, off_t Nzdata, int pixsize));
 int     gfits_compressed_data_pixsize   PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
 int     gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
@@ -279,5 +279,5 @@
 int     gfits_write_Theader            PROTO((char *filename, Header *header));
 
-int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype));
+int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype));
 int     gfits_uncompress_table         PROTO((FTable *srctable, FTable *tgttable));
 
Index: trunk/Ohana/src/libfits/matrix/F_compress_M.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_compress_M.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_compress_M.c	(revision 39457)
@@ -4,5 +4,5 @@
 # define VERBOSE_DUMP 0
 
-int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
+int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
 
 // the user needs to specify the various compression options:
@@ -23,5 +23,5 @@
 # define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
 
-int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype) {
+int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype) {
 
   int i;
@@ -33,5 +33,5 @@
   char *zdata = NULL;
 
-  int *ztile = Ztile;
+  unsigned long int *ztile = Ztile;
 
   Header *theader = ftable->header;
@@ -41,5 +41,5 @@
   // determine the number of tiles (from ztile[] and image size)
   if (!ztile) {
-    ALLOCATE (ztile, int, matrix->Naxes);
+    ALLOCATE (ztile, unsigned long int, matrix->Naxes);
     ztile[0] = matrix->Naxis[0];
     for (i = 1; i < matrix->Naxes; i++) ztile[i] = 1;
@@ -99,5 +99,5 @@
   for (i = 0; i < header->Naxes; i++) {
     snprintf (keyword, 10, "ZTILE%d", i + 1);
-    if (!gfits_modify (theader, keyword, "%d", 1, ztile[i])) ESCAPE;
+    if (!gfits_modify (theader, keyword, "%lu", 1, ztile[i])) ESCAPE;
   }
 
@@ -157,5 +157,5 @@
 
   // size (in pixels) of the largest tile
-  int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
+  unsigned long int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
 
   // size of a pixel in the raw pixel buffer (before compression)
@@ -179,5 +179,5 @@
 
   // allocate the buffer for compression work
-  int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
+  unsigned long int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
   ALLOCATE (raw,   char, raw_pixsize*max_tile_size);
   ALLOCATE (zdata, char, Nzdata_alloc);
@@ -191,5 +191,5 @@
 
     // size of the current tile in pixels
-    int Nraw = gfits_tile_size (matrix, otile, ztile);
+    unsigned long int Nraw = gfits_tile_size (matrix, otile, ztile);
 
     // copy the raw pixels from their native matrix locations to the temporary output buffer
@@ -216,5 +216,5 @@
       if (!gfits_byteswap_zdata (raw, Nraw * raw_pixsize, raw_pixsize)) ESCAPE;
     }
-    int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
+    unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
 
     if (VERBOSE_DUMP && (i == 0)) {
@@ -223,5 +223,5 @@
       for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", raw[k]); if (k % 4 == 3) fprintf (stderr, " "); } 
       fprintf (stderr, "\n");
-      fprintf (stderr, "Nzdata: %d -> ", Nzdata);
+      fprintf (stderr, "Nzdata: %lu -> ", Nzdata);
     }
 
@@ -231,5 +231,5 @@
     if (VERBOSE_DUMP && (i == 0)) {
       int k;
-      fprintf (stderr, "%d\n", Nzdata);
+      fprintf (stderr, "%lu\n", Nzdata);
       fprintf (stderr, "cmp SWP: "); 
       for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 
@@ -290,9 +290,14 @@
 
 int gfits_copy_keywords_compress (Header *srchead, Header *tgthead) {
-
+  OHANA_UNUSED_PARAM(tgthead);
+  OHANA_UNUSED_PARAM(srchead);
+
+# if (0)
   int i;
 
   for (i = 0; i < srchead->datasize; i += FT_LINE_LENGTH) {
   }
+# endif
+
   return TRUE;
 }
@@ -303,12 +308,12 @@
 // * ztile gives the size of the i-th dimension of the current tile
 // * raw_bitpix defines the size and type of the raw buffer
-int gfits_collect_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
-
-  int i, j, start, offset, coord, Nline;
-  int *counter = NULL;
-  int *Ztile = NULL;
-
-  ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
-  ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
+int gfits_collect_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
+
+  int i, k, start, offset, coord, Nline;
+  unsigned int *counter = NULL;
+  unsigned long int *Ztile = NULL;
+
+  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
+  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
   
   for (i = 0; i < matrix->Naxes; i++) {
@@ -343,4 +348,5 @@
   // this macro is used at the inner switch to run the actual loop
 # define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE, INTYPE) {			\
+    unsigned long int j;						\
     TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -356,4 +362,5 @@
   // this macro is used at the inner switch to run the actual loop
 # define SCALE_AND_DIST_INT(OTYPE, OSIZE) {				\
+    unsigned long int j;						\
     OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -370,4 +377,5 @@
   // this macro is used at the inner switch to run the actual loop
 # define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {				\
+    unsigned long int j;						\
     OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -419,13 +427,13 @@
 
     // update the counters, carrying to the next dimension if needed
-    for (j = 1; j < matrix->Naxes; j++) {
-      counter[j] ++;
-      if (counter[j] == Ztile[j]) {
-	counter[j] = 0;
+    for (k = 1; k < matrix->Naxes; k++) {
+      counter[k] ++;
+      if (counter[k] == Ztile[k]) {
+	counter[k] = 0;
       } else {
 	break;
       }
     }
-    if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
+    if (k == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
 
     // Naxes = 3
@@ -435,6 +443,6 @@
     // determine the offset of the next line relative to the start position
     offset = counter[matrix->Naxes - 1];
-    for (j = matrix->Naxes - 2; j >= 0; j--) {
-      offset = offset*matrix->Naxis[j] + counter[j];
+    for (k = matrix->Naxes - 2; k >= 0; k--) {
+      offset = offset*matrix->Naxis[k] + counter[k];
     }      
   }
@@ -453,24 +461,29 @@
 // * ztile gives the size of the i-th dimension of the current tile
 // * raw_bitpix defines the size and type of the raw buffer
-int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
-
-  int i, j, k;
-  int *counter = NULL;
-  int *Ztile = NULL;
-
-  ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
-  ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
+int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
+  OHANA_UNUSED_PARAM(oblank);
+  OHANA_UNUSED_PARAM(zblank);
+  OHANA_UNUSED_PARAM(zzero);
+  OHANA_UNUSED_PARAM(zscale);
+
+  unsigned long int i, j;
+  unsigned int *counter = NULL;
+  unsigned long int *Ztile = NULL;
+
+  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
+  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
   
-  for (i = 0; i < matrix->Naxes; i++) {
-    counter[i] = 0;
-    Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
+  int k;
+  for (k = 0; k < matrix->Naxes; k++) {
+    counter[k] = 0;
+    Ztile[k] = MIN ((matrix->Naxis[k] - otile[k]*ztile[k]), ztile[k]);
   }
 
   // number of lines in the tile (in pixels)
-  int Nline = 1;
-  int Npix = matrix->Naxis[0];
-  for (i = 1; i < matrix->Naxes; i++) {
-    Nline *= Ztile[i];
-    Npix  *= matrix->Naxis[i];
+  unsigned long int Nline = 1;
+  unsigned long int Npix = matrix->Naxis[0];
+  for (k = 1; k < matrix->Naxes; k++) {
+    Nline *= Ztile[k];
+    Npix  *= matrix->Naxis[k];
   }
 
@@ -482,7 +495,7 @@
   // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
   int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
-  for (i = matrix->Naxes - 2; i >= 0; i--) {
-    int coord = otile[i]*ztile[i];
-    start = start*matrix->Naxis[i] + coord;
+  for (k = matrix->Naxes - 2; k >= 0; k--) {
+    unsigned long int coord = otile[k]*ztile[k];
+    start = start*matrix->Naxis[k] + coord;
   }
   
@@ -519,13 +532,14 @@
 
       // update the counters, carrying to the next dimension if needed
-      for (j = 1; j < matrix->Naxes; j++) {
-	counter[j] ++;
-	if (counter[j] == Ztile[j]) {
-	  counter[j] = 0;
+      int axis;
+      for (axis = 1; axis < matrix->Naxes; axis++) {
+	counter[axis] ++;
+	if (counter[axis] == Ztile[axis]) {
+	  counter[axis] = 0;
 	} else {
 	  break;
 	}
       }
-      if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
+      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
 
       // Naxes = 3
@@ -535,6 +549,6 @@
       // determine the offset of the next line relative to the start position
       offset = counter[matrix->Naxes - 1];
-      for (j = matrix->Naxes - 2; j >= 0; j--) {
-	offset = offset*matrix->Naxis[j] + counter[j];
+      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
+	offset = offset*matrix->Naxis[axis] + counter[axis];
       }      
     }
Index: trunk/Ohana/src/libfits/matrix/F_compress_data.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_compress_data.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_compress_data.c	(revision 39457)
@@ -2,30 +2,5 @@
 # include <gfitsio.h>
 # include <zlib.h>
-
-/* functions defined in ricecomp.c */
-int fits_rcomp(int a[], int nx,	unsigned char *c, int clen, int nblock);
-int fits_rcomp_short(short a[], int nx, unsigned char *c, int clen, int nblock);
-int fits_rcomp_byte(char a[], int nx, unsigned char *c, int clen, int nblock);
-int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
-int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
-int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
-
-/* functions defined in fits_hcompress.c */
-# define LONGLONG long long
-int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
-int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
-
-/* functions defined in fits_hdeccompress.c */
-int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
-int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
-
-/* functions defined in pliocomp.c */
-int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
-int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
-
-/* functions defined in gzip.c */
-int gfits_gz_stripheader (unsigned char *data, int *ndata);
-int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
-int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
+# include <gfits_compress.h>
 
 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
@@ -33,10 +8,6 @@
 // XXX I'm putting Nx and Ny on the argument list -- only used by hcompress
 // with a little work, these could go on the option list
-int gfits_compress_data (char *zdata, int *Nzdata, char *cmptype, 
-			 char **optname, char **optvalue, int Nopt, 
-			 char *rawdata, int Nrawpix, int rawpix_size,
-			 int Nx, int Ny) {
+int gfits_compress_data (char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nrawpix, int rawpix_size, int Nx, int Ny) {
 
-  int Nout;
   int status;
 
@@ -68,4 +39,5 @@
 
   if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
+    long int Nout;
     int i, blocksize;
     // look for the BLOCKSIZE
@@ -85,6 +57,4 @@
     // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
 
-    int k;
-
     switch (rawpix_size) {
       case 4:
@@ -98,5 +68,6 @@
 
 	if (0) {
-	  fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix);
+	  long int k;
+	  fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nout, Nrawpix);
 	  fprintf (stderr, "cmp inp: "); 
 	  for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); } 
@@ -119,9 +90,9 @@
       return (FALSE);
     }
-    if (Nout > *Nzdata) {
-      fprintf (stderr, "buffer overrun! %d out, %d available\n", Nout, *Nzdata);
+    if (Nout > (long int) *Nzdata) {
+      fprintf (stderr, "buffer overrun! %ld out, %lu available\n", Nout, *Nzdata);
       return FALSE;
     }
-    *Nzdata = Nout;
+    *Nzdata = (unsigned long int) Nout;
     return TRUE;
   }
@@ -129,5 +100,5 @@
   if (!strcasecmp(cmptype, "PLIO_1")) {
     // note the fortan starting point: zdata is decremented at start
-    Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix);
+    int Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix);
     *Nzdata = Nout;
     if (!Nout) return (FALSE);
Index: trunk/Ohana/src/libfits/matrix/F_compress_utils.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_compress_utils.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_compress_utils.c	(revision 39457)
@@ -17,5 +17,5 @@
 
 typedef struct {
-  int *ztile; // max size of a tile (edge tiles may be smaller)
+  unsigned long int *ztile; // max size of a tile (edge tiles may be smaller)
   int *otile; // counter for current tile (eg, for (2,3,0) otile[0] = 2, otile[1] = 3, otile[2] = 0)
   int *ntile; // number of tiles in dimension [i]
@@ -23,5 +23,6 @@
 
 // advance the otile counter. 
-int gfits_imtile_next (Matrix *matrix, int *ztile, int *ntile, int *otile) {
+int gfits_imtile_next (Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile) {
+  OHANA_UNUSED_PARAM(ztile);
 
   int i;
@@ -53,5 +54,5 @@
 
 // how many tiles needed for this image (given ztile[])
-int gfits_imtile_count (Matrix *matrix, int *ztile, int *ntile) {
+int gfits_imtile_count (Matrix *matrix, unsigned long int *ztile, int *ntile) {
 
   int i;
@@ -67,9 +68,9 @@
 
 // how many tiles needed for this image (given ztile[])
-int gfits_imtile_maxsize (Matrix *matrix, int *ztile) {
+int gfits_imtile_maxsize (Matrix *matrix, unsigned long int *ztile) {
 
   int i;
 
-  int max_tile_size = 1;
+  unsigned long int max_tile_size = 1;
   for (i = 0; i < matrix->Naxes; i++) {
     max_tile_size *= ztile[i];
@@ -80,5 +81,5 @@
 
 // true sizes of this tile (in pixels)
-off_t gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {
+off_t gfits_tile_size (Matrix *matrix, int *otile, unsigned long int *ztile) {
 
   off_t i, Npixels, Ndimen;
@@ -93,5 +94,5 @@
 }
 
-int gfits_byteswap_zdata (char *zdata, int Nzdata, int pixsize) {
+int gfits_byteswap_zdata (char *zdata, off_t Nzdata, int pixsize) {
 
 # define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; }
@@ -99,5 +100,5 @@
 # ifdef BYTE_SWAP
 
-  int i;
+  off_t i;
 
   // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize);
Index: trunk/Ohana/src/libfits/matrix/F_convert_format.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_convert_format.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_convert_format.c	(revision 39457)
@@ -19,5 +19,5 @@
   in  = (inMode  *) matrix[0].buffer;			\
   for (i = 0; i < Npixels; i++, out++, in++)		\
-    if (*in == inBlank) {				\
+    if (*in == (inMode) inBlank) {			\
       *out = (MY_NAN);					\
     } else {						\
@@ -32,5 +32,5 @@
   in  = (inMode  *) matrix[0].buffer;		\
   for (i = 0; i < Npixels; i++, out++, in++)	\
-    if (*in == inBlank) {			\
+    if (*in == (inMode) inBlank) {			\
       *out = (MY_NAN);				\
     } else {					\
@@ -45,5 +45,5 @@
   in  = (inMode  *)matrix[0].buffer + Npixels - 1;	\
   for (i = 0; i < Npixels; i++, out--, in--)		\
-    if (*in == inBlank) {				\
+    if (*in == (inMode) inBlank) {				\
       *out = (MY_NAN);					\
     } else {						\
Index: trunk/Ohana/src/libfits/matrix/F_uncompress_M.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_uncompress_M.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_uncompress_M.c	(revision 39457)
@@ -4,43 +4,45 @@
 # define VERBOSE_DUMP 0
 
-int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
-
-# define ESCAPE { \
-  fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); \
-  if (ztile != NULL) free (ztile); \
-  if (optname != NULL) { \
-    for (j = 0; j < Noptions; j++) { \
-      free (optname[j]); \
-      free (optvalue[j]); \
-    } \
-    free (optname); \
-    free (optvalue); \
-  } \
-  if (out != NULL) free (out); \
-  if (otile != NULL) free (otile); \
-  if (ntile != NULL) free (ntile); \
-  return (FALSE); }
-
-# define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) { \
+int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
+
+# define ESCAPE {							\
+    fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__);	\
+    if (ztile != NULL) free (ztile);					\
+    if (optname != NULL) {						\
+      int opt;								\
+      for (opt = 0; opt < Noptions; opt++) {				\
+	free (optname[opt]);						\
+	free (optvalue[opt]);						\
+      }									\
+      free (optname);							\
+      free (optvalue);							\
+    }									\
+    if (out != NULL) free (out);					\
+    if (otile != NULL) free (otile);					\
+    if (ntile != NULL) free (ntile);					\
+    return (FALSE); }
+
+# define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) {	   \
     if (gfits_scan (header, ZNAME, TYPE, 1, IN)) { \
-      gfits_modify (header, NAME, TYPE, 1, OUT); \
-    } \
+      gfits_modify (header, NAME, TYPE, 1, OUT);   \
+    }						   \
     gfits_delete (header, ZNAME, 1); }
 
-# define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) { \
+# define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) {     \
     if (gfits_scan_alt (header, ZNAME, TYPE, 1, IN)) { \
-      gfits_modify_alt (header, NAME, TYPE, 1, OUT); \
-    } \
+      gfits_modify_alt (header, NAME, TYPE, 1, OUT);   \
+    }						       \
     gfits_delete (header, ZNAME, 1); }
 
-# define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) { \
-  if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE; \
-  gfits_delete (header, ZNAME, 1); \
-  gfits_modify (header, NAME, TYPE, 1, OUT); }
+# define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) {		\
+    if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE;	\
+    gfits_delete (header, ZNAME, 1);				\
+    gfits_modify (header, NAME, TYPE, 1, OUT); }
 
 int gfits_uncompress_image (Header *header, Matrix *matrix, FTable *ftable) {
 
+  int status, zimage;
   off_t Nzdata, Nzrows, zcol;
-  int i, j, status, zimage, Nout, max_tile_size;
+  unsigned long int max_tile_size;
   char cmptype[80];
   char zaxis[10], naxis[10], key[10], word[81], exttype[81], checksum[81], datasum[81];
@@ -49,5 +51,5 @@
   float zscale, zzero;
 
-  int *ztile = NULL;
+  unsigned long int *ztile = NULL;
   int *otile = NULL;
   int *ntile = NULL;
@@ -77,8 +79,9 @@
   MOD_KEYWORD_REQUIRED ("ZNAXIS",  "NAXIS",  "%d", &header->Naxes,  header->Naxes);
 
-  for (i = 0; i < header->Naxes; i++) {
-    snprintf (zaxis, 10, "ZNAXIS%d", i + 1);
-    snprintf (naxis, 10, "NAXIS%d", i + 1);
-    MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[i],  header->Naxis[i]);
+  int axis;
+  for (axis = 0; axis < header->Naxes; axis++) {
+    snprintf (zaxis, 10, "ZNAXIS%d", axis + 1);
+    snprintf (naxis, 10, "NAXIS%d", axis + 1);
+    MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[axis],  header->Naxis[axis]);
   }    
 
@@ -86,15 +89,15 @@
   // the actual tile size may be smaller at the edge of a dimension.  if the ZTILEn
   // entries are not found, default to [Nx,1,1,...]
-  ALLOCATE (ztile, int, header->Naxes);
-  if (!gfits_scan (header, "ZTILE1", "%d", 1, &ztile[0])) {
+  ALLOCATE (ztile, unsigned long int, header->Naxes);
+  if (!gfits_scan (header, "ZTILE1", "%lu", 1, &ztile[0])) {
     ztile[0] = header->Naxis[0];
-    for (i = 1; i < header->Naxes; i++) {
-      ztile[i] = 1;
+    for (axis = 1; axis < header->Naxes; axis++) {
+      ztile[axis] = 1;
     }
   } else {
     gfits_delete (header, "ZTILE1", 1);
-    for (i = 1; i < header->Naxes; i++) {
-      snprintf (key, 10, "ZTILE%d", i + 1);
-      if (!gfits_scan (header, key, "%d", 1, &ztile[i])) ESCAPE;
+    for (axis = 1; axis < header->Naxes; axis++) {
+      snprintf (key, 10, "ZTILE%d", axis + 1);
+      if (!gfits_scan (header, key, "%lu", 1, &ztile[axis])) ESCAPE;
       gfits_delete (header, key, 1);
     }
@@ -199,10 +202,11 @@
   // find the COMPRESSED_DATA column (format should be 1PB, 1PI, 1PJ)
   // is it required that this be the only column?
-  for (i = 1; TRUE; i++) {
-    snprintf (key, 10, "TTYPE%d", i);
+  int colnum;
+  for (colnum = 1; TRUE; colnum++) {
+    snprintf (key, 10, "TTYPE%d", colnum);
     if (!gfits_scan (ftable->header, key, "%s", 1, word)) ESCAPE;
     if (!strcmp (word, "COMPRESSED_DATA")) break;
   }
-  zcol = i;
+  zcol = colnum;
 
   if (!gfits_varlength_column_define (ftable, &zdef, zcol)) ESCAPE;
@@ -220,12 +224,12 @@
   ALLOCATE (ntile, int, matrix->Naxes);
   max_tile_size = 1;
-  for (i = 0; i < matrix->Naxes; i++) {
-    otile[i] = 0;
-    ntile[i] = (matrix->Naxis[i] % ztile[i]) ? (matrix->Naxis[i] / ztile[i] + 1) : (matrix->Naxis[i] / ztile[i]);
-    max_tile_size *= ztile[i];
-
-    // ztile[i] is the default (or max) tile size in the i-th dimension
-    // ntile[i] is the number of tiles in the i-th dimension
-    // otile[i] is the current output tile counter in the i-th dimension
+  for (axis = 0; axis < matrix->Naxes; axis++) {
+    otile[axis] = 0;
+    ntile[axis] = (matrix->Naxis[axis] % ztile[axis]) ? (matrix->Naxis[axis] / ztile[axis] + 1) : (matrix->Naxis[axis] / ztile[axis]);
+    max_tile_size *= ztile[axis];
+
+    // ztile[axis] is the default (or max) tile size in the i-th dimension
+    // ntile[axis] is the number of tiles in the i-th dimension
+    // otile[axis] is the current output tile counter in the i-th dimension
   }
 
@@ -254,5 +258,5 @@
   // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
 
-  int Nout_alloc = raw_pixsize*max_tile_size;
+  unsigned long int Nout_alloc = raw_pixsize*max_tile_size;
   ALLOCATE (out, char, Nout_alloc);
 
@@ -271,5 +275,5 @@
 
     // expected output size for this tile
-    Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
+    unsigned long Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
 
     zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata);
@@ -297,5 +301,5 @@
       for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 
       fprintf (stderr, "\n");
-      fprintf (stderr, "Nout  : %d -> ", Nout);
+      fprintf (stderr, "Nout  : %lu -> ", Nout);
     }
     
@@ -307,5 +311,5 @@
     if (VERBOSE_DUMP && (row == 0)) {
       int k;
-      fprintf (stderr, "%d\n", Nout);
+      fprintf (stderr, "%lu\n", Nout);
       fprintf (stderr, "unc swp: "); 
       for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); } 
@@ -315,5 +319,5 @@
     if (!strcasecmp(cmptype, "GZIP_1")) {
       // Nout is number of pixels
-      if (!gfits_byteswap_zdata (out, Nout * raw_pixsize, raw_pixsize)) ESCAPE;
+      if (!gfits_byteswap_zdata (out, (off_t) (Nout * raw_pixsize), raw_pixsize)) ESCAPE;
     }
     
@@ -340,8 +344,8 @@
 
     // update the tile counters, carrying to the next dimension if needed
-    for (j = 0; j < matrix->Naxes; j++) {
-      otile[j] ++;
-      if (otile[j] == ntile[j]) {
-	otile[j] = 0;
+    for (axis = 0; axis < matrix->Naxes; axis++) {
+      otile[axis] ++;
+      if (otile[axis] == ntile[axis]) {
+	otile[axis] = 0;
       } else {
 	break;
@@ -352,7 +356,8 @@
   FREE (ztile);
   if (optname != NULL) {
-    for (j = 0; j < Noptions; j++) {
-      FREE (optname[j]);
-      FREE (optvalue[j]);
+    int opt;
+    for (opt = 0; opt < Noptions; opt++) {
+      FREE (optname[opt]);
+      FREE (optvalue[opt]);
     }
     FREE (optname);
@@ -366,24 +371,24 @@
 
 // bitpix is the input data size/type
-int gfits_distribute_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
-
-  int i, j;
-  int *counter = NULL;
-  int *Ztile = NULL;
-
-  ALLOCATE (counter, int, matrix->Naxes);
-  ALLOCATE (Ztile, int, matrix->Naxes);
+int gfits_distribute_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
+
+  int axis;
+  unsigned int *counter = NULL;
+  unsigned long int *Ztile = NULL;
+
+  ALLOCATE (counter, unsigned int, matrix->Naxes);
+  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
 
   // counter for current row in tile to copy
   // true sizes of this tile (in pixels)
-  for (i = 0; i < matrix->Naxes; i++) {
-    counter[i] = 0;
-    Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
+  for (axis = 0; axis < matrix->Naxes; axis++) {
+    counter[axis] = 0;
+    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
   }
 
   // number of lines in the tile (in pixels)
-  int Nline = 1;
-  for (i = 1; i < matrix->Naxes; i++) {
-    Nline *= Ztile[i];
+  unsigned long int Nline = 1;
+  for (axis = 1; axis < matrix->Naxes; axis++) {
+    Nline *= Ztile[axis];
   }
 
@@ -394,16 +399,17 @@
   // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
   // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
-  int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
-  for (i = matrix->Naxes - 2; i >= 0; i--) {
-    int coord = otile[i]*ztile[i];
-    start = start*matrix->Naxis[i] + coord;
+  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
+  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
+    unsigned long int coord = otile[axis]*ztile[axis];
+    start = start*matrix->Naxis[axis] + coord;
   }
   
   // pixel offset in output array relative to tile start
-  int offset = 0;
+  unsigned long int offset = 0;
 
   int directCopy = (zzero == 0.0) && (zscale == 1.0);
 
 # define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE) {				\
+    unsigned long j;							\
     TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -418,4 +424,5 @@
   // this macro is used at the inner switch to run the actual loop
 # define SCALE_AND_DIST_INT(OTYPE, OSIZE) {				\
+    unsigned long j;							\
     OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -432,4 +439,5 @@
   // this macro is used at the inner switch to run the actual loop
 # define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {				\
+    unsigned long j;							\
     OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)];	\
     for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {		\
@@ -461,5 +469,5 @@
       case   8: SCALE_AND_DIST_INT   (char,   1); break; \
       case  16: SCALE_AND_DIST_INT   (short,  2); break; \
-      case  32: SCALE_AND_DIST_INT (int,    4); break; \
+      case  32: SCALE_AND_DIST_INT   (int,    4); break; \
       case -32: SCALE_AND_DIST_FLOAT (float,  4); break; \
       case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \
@@ -468,4 +476,5 @@
 
   // loop over lines in the tile
+  unsigned long int i;
   for (i = 0; i < Nline; i++) {
     switch (raw_bitpix) {
@@ -479,13 +488,13 @@
 
     // update the counters, carrying to the next dimension if needed
-    for (j = 1; j < matrix->Naxes; j++) {
-      counter[j] ++;
-      if (counter[j] == Ztile[j]) {
-	counter[j] = 0;
+    for (axis = 1; axis < matrix->Naxes; axis++) {
+      counter[axis] ++;
+      if (counter[axis] == Ztile[axis]) {
+	counter[axis] = 0;
       } else {
 	break;
       }
     }
-    if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
+    if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
 
     // Naxes = 3
@@ -495,6 +504,6 @@
     // determine the offset of the next line relative to the start position
     offset = counter[matrix->Naxes - 1];
-    for (j = matrix->Naxes - 2; j >= 0; j--) {
-      offset = offset*matrix->Naxis[j] + counter[j];
+    for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
+      offset = offset*matrix->Naxis[axis] + counter[axis];
     }      
   }
@@ -506,26 +515,30 @@
 
 // bitpix is the input data size/type
-int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
-
-  int i, j, k;
-  int *counter = NULL;
-  int *Ztile = NULL;
-
-  ALLOCATE (counter, int, matrix->Naxes);
-  ALLOCATE (Ztile, int, matrix->Naxes);
+int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
+  OHANA_UNUSED_PARAM(oblank);
+  OHANA_UNUSED_PARAM(zblank);
+  OHANA_UNUSED_PARAM(zzero);
+  OHANA_UNUSED_PARAM(zscale);
+
+  int axis;
+  unsigned int *counter = NULL;
+  unsigned long int *Ztile = NULL;
+
+  ALLOCATE (counter, unsigned int, matrix->Naxes);
+  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
 
   // counter for current row in tile to copy
   // true sizes of this tile (in pixels)
-  for (i = 0; i < matrix->Naxes; i++) {
-    counter[i] = 0;
-    Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
+  for (axis = 0; axis < matrix->Naxes; axis++) {
+    counter[axis] = 0;
+    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
   }
 
   // number of lines in the tile (in pixels)
-  int Nline = 1;
-  int Npix = matrix->Naxis[0];
-  for (i = 1; i < matrix->Naxes; i++) {
-    Nline *= Ztile[i];
-    Npix  *= matrix->Naxis[i];
+  unsigned long int Nline = 1;
+  unsigned long int Npix = matrix->Naxis[0];
+  for (axis = 1; axis < matrix->Naxes; axis++) {
+    Nline *= Ztile[axis];
+    Npix  *= matrix->Naxis[axis];
   }
 
@@ -536,8 +549,8 @@
   // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
   // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
-  int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
-  for (i = matrix->Naxes - 2; i >= 0; i--) {
-    int coord = otile[i]*ztile[i];
-    start = start*matrix->Naxis[i] + coord;
+  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
+  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
+    unsigned long int coord = otile[axis]*ztile[axis];
+    start = start*matrix->Naxis[axis] + coord;
   }
   
@@ -553,8 +566,10 @@
 
   // pixel offset in output array relative to tile start
-  int offset = 0;
+  unsigned long int offset = 0;
 
   static int pass = 0;
+  int k;
   for (k = 0; k < size; k++) {
+    unsigned long int i;
     for (i = 0; i < Nline; i++) {
 # ifdef BYTE_SWAP      
@@ -564,4 +579,5 @@
 # endif
       char *rawptr = &raw[i*Ztile[0] + k*Nraw];	
+      unsigned long j;
       for (j = 0; j < Ztile[0]; j++, srcptr += size, rawptr ++) {		
 	if (FALSE && (i == 0) && (j < 4) && (pass == 0)) {
@@ -574,13 +590,13 @@
 
       // update the counters, carrying to the next dimension if needed
-      for (j = 1; j < matrix->Naxes; j++) {
-	counter[j] ++;
-	if (counter[j] == Ztile[j]) {
-	  counter[j] = 0;
+      for (axis = 1; axis < matrix->Naxes; axis++) {
+	counter[axis] ++;
+	if (counter[axis] == Ztile[axis]) {
+	  counter[axis] = 0;
 	} else {
 	  break;
 	}
       }
-      if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
+      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
 
       // Naxes = 3
@@ -590,6 +606,6 @@
       // determine the offset of the next line relative to the start position
       offset = counter[matrix->Naxes - 1];
-      for (j = matrix->Naxes - 2; j >= 0; j--) {
-	offset = offset*matrix->Naxis[j] + counter[j];
+      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
+	offset = offset*matrix->Naxis[axis] + counter[axis];
       }      
     }
Index: trunk/Ohana/src/libfits/matrix/F_uncompress_data.c
===================================================================
--- trunk/Ohana/src/libfits/matrix/F_uncompress_data.c	(revision 39399)
+++ trunk/Ohana/src/libfits/matrix/F_uncompress_data.c	(revision 39457)
@@ -2,31 +2,9 @@
 # include <gfitsio.h>
 # include <zlib.h>
-
-/* functions defined in ricecomp.c */
-int fits_rcomp(int a[], int nx,	unsigned char *c, int clen, int nblock);
-int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
-int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
-int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
-
-/* functions defined in fits_hcompress.c */
-# define LONGLONG long long
-int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
-int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
-
-/* functions defined in fits_hdeccompress.c */
-int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
-int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
-
-/* functions defined in pliocomp.c */
-int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
-int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
-
-/* functions defined in gzip.c */
-int gfits_gz_stripheader (unsigned char *data, int *ndata);
-int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
+# include <gfits_compress.h>
 
 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
 
-int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) {
+int gfits_uncompress_data (char *zdata, unsigned long Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize) {
 
   int status;
@@ -78,6 +56,5 @@
 
     int status = FALSE;
-    int Npix = *Nout / out_pixsize;
-    int k;
+    unsigned long int Npix = *Nout / out_pixsize;
 
     switch (out_pixsize) {
@@ -88,5 +65,6 @@
       case 2:
 	if (0) {
-	  fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix);
+	  unsigned long int k;
+	  fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nzdata, Npix);
 	  fprintf (stderr, "cmp out: "); 
 	  for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
@@ -112,7 +90,8 @@
   
   if (!strcasecmp(cmptype, "PLIO_1")) {
+    int Ntru = *Nout;
     int Npix;
-    Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, *Nout);
-    if (Npix != *Nout) {
+    Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, Ntru);
+    if (Npix != Ntru) {
       fprintf (stderr, "error in plio decompression\n");
       return (FALSE);
@@ -122,4 +101,5 @@
 
   if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
+    unsigned long int Ntru = *Nout;
     int Nx, Ny, scale;
     status = 0;
@@ -132,5 +112,6 @@
     // fprintf (stderr, "decompression yields image %d x %d (scale: %d)\n", Nx, Ny, scale);
     
-    if (Nx * Ny != *Nout) {
+    unsigned long Npix = Nx * Ny;
+    if (Npix != Ntru) {
       fprintf (stderr, "error in hdecompress: mismatched output size\n");
       return (FALSE);
Index: trunk/Ohana/src/libfits/table/F_compress_T.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_compress_T.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_compress_T.c	(revision 39457)
@@ -23,6 +23,6 @@
 # define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
 
-int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
-int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
+int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
+int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
 
 static float timeSum1 = 0.0;
@@ -51,7 +51,5 @@
 }
 
-int gfits_compress_table (FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype) {
-
-  int i, j;
+int gfits_compress_table (FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype) {
 
   char keyword[81];
@@ -69,5 +67,5 @@
   gettimeofday (&startTimer, (void *) NULL);
 
-  int Ntile, ztilelast;
+  unsigned long int Ntile, ztilelast;
   if (!ztilelen) ztilelen = srcheader->Naxis[1];
 
@@ -104,26 +102,27 @@
 
   ALLOCATE_ZERO (fields, TableField, Nfields);
-  for (i = 0; i < Nfields; i++) {
-    snprintf (keyword, 80, "TTYPE%d", i+1);
-    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].ttype)) ESCAPE;
-    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].ttype_cmt)) ESCAPE;
+
+  for (int field = 0; field < Nfields; field++) {
+    snprintf (keyword, 80, "TTYPE%d", field+1);
+    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].ttype)) ESCAPE;
+    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].ttype_cmt)) ESCAPE;
 
     // TUNIT is not mandatory
-    snprintf (keyword, 80, "TUNIT%d", i+1);
-    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tunit)) {
-      fields[i].tunit[0] = 0;
+    snprintf (keyword, 80, "TUNIT%d", field+1);
+    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tunit)) {
+      fields[field].tunit[0] = 0;
     } else {
-      if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tunit_cmt)) ESCAPE;
+      if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tunit_cmt)) ESCAPE;
     }
     
-    snprintf (keyword, 80, "TFORM%d", i+1);
-    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
-    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE;
+    snprintf (keyword, 80, "TFORM%d", field+1);
+    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
+    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tformat_cmt)) ESCAPE;
 
     // for now we set all fields to the requested type.  since I do not yet know the column data types I cannot yet assign automatic cmptypes
-    strcpy (fields[i].zctype, zcmptype);
+    strcpy (fields[field].zctype, zcmptype);
 
     // by using "P" format, we are limited to 32bit pointers (2GB heap)
-    if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[i].ttype, fields[i].ttype_cmt, fields[i].tunit, 1.0, 0.0)) ESCAPE;
+    if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[field].ttype, fields[field].ttype_cmt, fields[field].tunit, 1.0, 0.0)) ESCAPE;
   }    
 
@@ -137,6 +136,6 @@
   char *tmpbuffer = NULL;
   ALLOCATE_ZERO (tmpbuffer, char, 16*Ntile); // need space for Ntile entries, each of width 16 bytes (2 long)
-  for (i = 0; i < Nfields; i++) {
-    if (!gfits_set_bintable_column (tgtheader, tgttable, fields[i].ttype, tmpbuffer, Ntile)) ESCAPE;
+  for (int field = 0; field < Nfields; field++) {
+    if (!gfits_set_bintable_column (tgtheader, tgttable, fields[field].ttype, tmpbuffer, Ntile)) ESCAPE;
   }
   free (tmpbuffer);
@@ -146,5 +145,5 @@
 
   // define compression-specific keywords, update header as needed.
-  if (!gfits_modify (tgtheader, "ZTILELEN", "%d", 1, ztilelen)) ESCAPE;
+  if (!gfits_modify (tgtheader, "ZTILELEN", "%lu", 1, ztilelen)) ESCAPE;
 
   if (!gfits_modify (tgtheader, "ZNAXIS1", OFF_T_FMT, 1, srcheader->Naxis[0])) ESCAPE;
@@ -163,27 +162,27 @@
   int offset = 0; // bytes from first column of first field to the current field (accumulate to set)
 
-  for (i = 0; i < Nfields; i++) {
-    snprintf (keyword, 81, "ZFORM%d", i+1);
-    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
-    if (!gfits_varlength_column_define (tgttable, &fields[i].zdef, i+1)) ESCAPE;
-    if (!gfits_bintable_format (fields[i].tformat, fields[i].datatype, &fields[i].Nvalues, &fields[i].pixsize)) ESCAPE; // 
-    fields[i].rowsize = fields[i].Nvalues*fields[i].pixsize;
-    max_width = MAX(max_width, fields[i].rowsize);
-
-    if (!strcasecmp (fields[i].zctype, "AUTO")) {
-      if (!strcmp (fields[i].datatype, "short") ||
-	  !strcmp (fields[i].datatype, "float") || 
-	  !strcmp (fields[i].datatype, "double")|| 
-	  !strcmp (fields[i].datatype, "int64_t")) {
-	strcpy (fields[i].zctype, "GZIP_2");
+  for (int field = 0; field < Nfields; field++) {
+    snprintf (keyword, 81, "ZFORM%d", field+1);
+    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
+    if (!gfits_varlength_column_define (tgttable, &fields[field].zdef, field+1)) ESCAPE;
+    if (!gfits_bintable_format (fields[field].tformat, fields[field].datatype, &fields[field].Nvalues, &fields[field].pixsize)) ESCAPE; // 
+    fields[field].rowsize = fields[field].Nvalues*fields[field].pixsize;
+    max_width = MAX(max_width, fields[field].rowsize);
+
+    if (!strcasecmp (fields[field].zctype, "AUTO")) {
+      if (!strcmp (fields[field].datatype, "short") ||
+	  !strcmp (fields[field].datatype, "float") || 
+	  !strcmp (fields[field].datatype, "double")|| 
+	  !strcmp (fields[field].datatype, "int64_t")) {
+	strcpy (fields[field].zctype, "GZIP_2");
 	goto got_cmptype;
       }
-      if (!strcmp (fields[i].datatype, "int")) {
-	strcpy (fields[i].zctype, "RICE_1");
+      if (!strcmp (fields[field].datatype, "int")) {
+	strcpy (fields[field].zctype, "RICE_1");
 	goto got_cmptype;
       }
-      if (!strcmp (fields[i].datatype, "byte") ||
-	  !strcmp (fields[i].datatype, "char")) {
-	strcpy (fields[i].zctype, "GZIP_1");
+      if (!strcmp (fields[field].datatype, "byte") ||
+	  !strcmp (fields[field].datatype, "char")) {
+	strcpy (fields[field].zctype, "GZIP_1");
 	goto got_cmptype;
       }
@@ -193,25 +192,25 @@
 
     // OVERRIDE: RICE can only be used on integer fields
-    if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) {
-      if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") || !strcmp (fields[i].datatype, "int64_t")) {
-	strcpy (fields[i].zctype, "GZIP_2");
+    if (!strcasecmp (fields[field].zctype, "RICE_1") || !strcasecmp (fields[field].zctype, "RICE_ONE")) {
+      if (!strcmp (fields[field].datatype, "float") || !strcmp (fields[field].datatype, "double") || !strcmp (fields[field].datatype, "int64_t")) {
+	strcpy (fields[field].zctype, "GZIP_2");
       }
     }
 
     // OVERRIDE: GZIP_2 invalid for B (use GZIP_1)
-    if (!strcasecmp (fields[i].zctype, "GZIP_2") && !strcmp (fields[i].datatype, "byte")) {
-      strcpy (fields[i].zctype, "GZIP_1");
+    if (!strcasecmp (fields[field].zctype, "GZIP_2") && !strcmp (fields[field].datatype, "byte")) {
+      strcpy (fields[field].zctype, "GZIP_1");
     }
 
     // compression type per column (XXX for now we are just using zcmptype, as set above)
-    snprintf (keyword, 81, "ZCTYP%d", i+1);
-    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].zctype)) ESCAPE;
-
-    fields[i].offset = offset;
-    offset += fields[i].rowsize;
+    snprintf (keyword, 81, "ZCTYP%d", field+1);
+    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].zctype)) ESCAPE;
+
+    fields[field].offset = offset;
+    offset += fields[field].rowsize;
   }
 
   // allocate the intermediate storage buffers
-  int Nzdata_alloc = 2*max_width*ztilelen + 100;
+  unsigned long int Nzdata_alloc = 2*max_width*ztilelen + 100;
   ALLOCATE (raw,   char, max_width*ztilelen);
   ALLOCATE (zdata, char, Nzdata_alloc);
@@ -229,20 +228,20 @@
   // compress the data : copy into a tile, compress the tile, then add to the output table
   // each tile -> 1 row of the output table
-  for (i = 0; i < Ntile; i++) {
-
-    for (j = 0; j < Nfields; j++) {
-
-      gettimeofday (&startTimer, (void *) NULL);
-
-      int Nrows = (i == Ntile - 1) ? ztilelast : ztilelen;
-      int row_start = i*ztilelen; 
+  for (unsigned long int tile = 0; tile < Ntile; tile++) {
+
+    for (int field = 0; field < Nfields; field++) {
+
+      gettimeofday (&startTimer, (void *) NULL);
+
+      unsigned long int Nrows = (tile == Ntile - 1) ? ztilelast : ztilelen;
+      unsigned long int row_start = tile*ztilelen; 
       // ^- first row for this tile & field
       // NOTE: assumes each tile has the same length, ex the last (true for now)
 
       // copy the raw pixels from their native matrix locations to the temporary output buffer
-      if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) {
-	if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
+      if (!strcasecmp(fields[field].zctype, "GZIP_2") || !strcasecmp(fields[field].zctype, "NONE_2")) {
+	if (!gfits_collect_table_gzp2 (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
       } else {
-	if (!gfits_collect_table_data (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
+	if (!gfits_collect_table_data (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
       }
       
@@ -256,7 +255,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "c1: ");
-	for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
+	for (unsigned long int k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
 	  fprintf (stderr, "%02hhx", raw[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -269,7 +267,7 @@
       // optname, optvalue = NULL, Noptions = 0
       
-      int Nraw = Nrows*fields[j].Nvalues; // number of pixels
-      if (!strcasecmp(fields[j].zctype, "GZIP_1")) {
-	if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE;
+      unsigned long int Nraw = Nrows*fields[field].Nvalues; // number of pixels
+      if (!strcasecmp(fields[field].zctype, "GZIP_1")) {
+	if (!gfits_byteswap_zdata (raw, Nraw * fields[field].pixsize, fields[field].pixsize)) ESCAPE;
       }
 
@@ -281,7 +279,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "c2: ");
-	for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
+	for (unsigned long int k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
 	  fprintf (stderr, "%02hhx", raw[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -291,6 +288,6 @@
       }
 
-      int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
-      if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE;
+      unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
+      if (!gfits_compress_data (zdata, &Nzdata, fields[field].zctype, NULL, NULL, 0, raw, Nraw, fields[field].pixsize, 0, 0)) ESCAPE;
       
       // XXX TIMER 2c
@@ -301,7 +298,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "c3: ");
-	for (k = 0; k < Nzdata; k++) {
+	for (unsigned long int k = 0; k < Nzdata; k++) {
 	  fprintf (stderr, "%02hhx", zdata[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -311,10 +307,10 @@
       }
 
-      if (strcasecmp(fields[j].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
-	  strcasecmp(fields[j].zctype, "GZIP_1") &&
-	  strcasecmp(fields[j].zctype, "GZIP_2") && 
-	  strcasecmp(fields[j].zctype, "RICE_1") && 
-	  strcasecmp(fields[j].zctype, "RICE_ONE")) {
-	if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE;
+      if (strcasecmp(fields[field].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
+	  strcasecmp(fields[field].zctype, "GZIP_1") &&
+	  strcasecmp(fields[field].zctype, "GZIP_2") && 
+	  strcasecmp(fields[field].zctype, "RICE_1") && 
+	  strcasecmp(fields[field].zctype, "RICE_ONE")) {
+	if (!gfits_byteswap_zdata (zdata, Nzdata, fields[field].pixsize)) ESCAPE;
       }
 
@@ -326,7 +322,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "c4: ");
-	for (k = 0; k < Nzdata; k++) {
+	for (unsigned long int k = 0; k < Nzdata; k++) {
 	  fprintf (stderr, "%02hhx", zdata[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -336,5 +331,5 @@
       }
 
-      if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, i, &fields[j].zdef)) ESCAPE;
+      if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, tile, &fields[field].zdef)) ESCAPE;
       // XXX TIMER 2e
       gettimeofday (&stopTimer, (void *) NULL); 
@@ -347,6 +342,6 @@
   if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
 
-  for (i = 0; i < Nfields; i++) {
-    if (!gfits_varlength_column_finish (tgttable, &fields[i].zdef)) ESCAPE;
+  for (int field = 0; field < Nfields; field++) {
+    if (!gfits_varlength_column_finish (tgttable, &fields[field].zdef)) ESCAPE;
   }
 
@@ -375,7 +370,5 @@
 // raw_pixsize is the bytes / pixel for the input matrix
 // place the raw image bytes for the current tile into the tile buffer
-int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
-
-  off_t i;
+int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
 
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
@@ -388,8 +381,8 @@
 
   if (VERBOSE) fprintf (stderr, "distribute: ");
-  for (i = 0; i < Nrows; i++, tblbuffer += Nx) {
+  for (unsigned long i = 0; i < Nrows; i++, tblbuffer += Nx) {
     memcpy (&raw[i*rowsize], tblbuffer, rowsize);
 # if (VERBOSE)
-    int j; for (j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
+    for (int j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
 # endif
   }
@@ -399,7 +392,5 @@
 }
 
-int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
-
-  off_t i;
+int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
 
   // we are copying NN rows of the column which starts at XX and has MM bytes per row
@@ -408,5 +399,5 @@
 
   if (VERBOSE) fprintf (stderr, "collect: ");
-  for (i = 0; i < Nrows; i++) {
+  for (unsigned long i = 0; i < Nrows; i++) {
     int row = row_start + i;
     memcpy (&raw[i*field->rowsize], &table->buffer[Nx*row + field->offset], field->rowsize);
@@ -420,7 +411,5 @@
 }
 
-int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
-
-  off_t i, j, k;
+int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
 
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
@@ -433,5 +422,5 @@
   char *rawptr = raw;
 
-  for (k = 0; k < field->pixsize; k++) {
+  for (off_t k = 0; k < field->pixsize; k++) {
 # ifdef BYTE_SWAP      
     char *tblptr_start = &table->buffer[Nx*row_start + offset + (pixsize - k - 1)];
@@ -439,7 +428,7 @@
     char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
 # endif
-    for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
+    for (unsigned long int i = 0; i < Nrows; i++, tblptr_start += Nx) {
       char *tblptr = tblptr_start;
-      for (j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
+      for (off_t j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
 	*rawptr = *tblptr;
       }
@@ -449,7 +438,5 @@
 }
 
-int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
-
-  off_t i, j, k;
+int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
 
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
@@ -457,7 +444,7 @@
   off_t Nx = table->header->Naxis[0];
 
-  for (k = 0; k < field->pixsize; k++) {
-    for (i = 0; i < Nrows; i++) {
-      int row = row_start + i;
+  for (off_t k = 0; k < field->pixsize; k++) {
+    for (unsigned long int i = 0; i < Nrows; i++) {
+      unsigned long int row = row_start + i;
       char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
 # ifdef BYTE_SWAP      
@@ -466,7 +453,8 @@
       char *tblptr = &table->buffer[Nx*row + field->offset + k];
 # endif
-      for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
+      for (off_t j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
 	*rawptr = *tblptr;
-	myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops");
+	myAssert (rawptr >= raw, "oops");
+	myAssert ((unsigned long int)(rawptr - raw) < Nrows*field->Nvalues*field->pixsize, "oops");
 	myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops");
       }
Index: trunk/Ohana/src/libfits/table/F_set_column.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_set_column.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_set_column.c	(revision 39457)
@@ -109,5 +109,5 @@
   if (CHECK_MEMBLOCKS) {
     OhanaMemblock *ref = (OhanaMemblock *) array - 1;
-    fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
+    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
     if (!ref->nextBlock && !ref->prevBlock) abort();
   }
@@ -120,5 +120,5 @@
   if (CHECK_MEMBLOCKS) {
     OhanaMemblock *ref = (OhanaMemblock *) array - 1;
-    fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
+    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
     if (!ref->nextBlock && !ref->prevBlock) abort();
   }
@@ -212,5 +212,5 @@
   if (CHECK_MEMBLOCKS) {
     OhanaMemblock *ref = (OhanaMemblock *) array - 1;
-    fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
+    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
     if (!ref->nextBlock && !ref->prevBlock) abort();
   }
@@ -241,5 +241,5 @@
   if (CHECK_MEMBLOCKS) {
     OhanaMemblock *ref = (OhanaMemblock *) array - 1;
-    fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
+    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
     if (!ref->nextBlock && !ref->prevBlock) abort();
   }
Index: trunk/Ohana/src/libfits/table/F_table_varlength.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_table_varlength.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_table_varlength.c	(revision 39457)
@@ -187,4 +187,5 @@
     ptr[0] = Ndata;
     ptr[1] = heap_offset - table->heap_start;
+    // fprintf (stderr, "row: %d, Ndata: %d, maxlen: %d, Ndata: %d, ptr1: %d\n", (int) row, (int) Ndata, (int) column->maxlen, (int) Ndata, (int) (heap_offset - table->heap_start));
   }
 
Index: trunk/Ohana/src/libfits/table/F_uncompress_T.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_uncompress_T.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_uncompress_T.c	(revision 39457)
@@ -13,7 +13,6 @@
 int gfits_dump_raw_table (FTable *table, char *message) {
 # if (VERBOSE_DUMP)
-  int i;
   fprintf (stderr, "%s data:\n", message);
-  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+  for (int i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
     // for (i = 0; i < 16; i++) {
     fprintf (stderr, "%02hhx", table->buffer[i]);
@@ -22,4 +21,7 @@
   }
   fprintf (stderr, "\n");
+# else
+  OHANA_UNUSED_PARAM(table);
+  OHANA_UNUSED_PARAM(message);
 # endif
   return TRUE;
@@ -28,7 +30,6 @@
 int gfits_dump_cmp_table (FTable *table, char *message) {
 # if (VERBOSE_DUMP)
-  int i;
   fprintf (stderr, "%s pntr:\n", message);
-  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+  for (int i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
     fprintf (stderr, "%02hhx", table->buffer[i]);
     if (i % 2) fprintf (stderr, " ");
@@ -38,5 +39,5 @@
 
   fprintf (stderr, "%s data:\n", message);
-  for (i = 0; i < table->header->pcount; i++) {
+  for (int i = 0; i < table->header->pcount; i++) {
     fprintf (stderr, "%02hhx", table->buffer[table->heap_start + i]);
     if (i % 2) fprintf (stderr, " ");
@@ -44,4 +45,7 @@
   }
   fprintf (stderr, "\n");
+# else
+  OHANA_UNUSED_PARAM(table);
+  OHANA_UNUSED_PARAM(message);
 # endif
   return TRUE;
@@ -77,6 +81,4 @@
 int gfits_uncompress_table (FTable *srctable, FTable *tgttable) {
 
-  int i;
-
   char keyword[256];
 
@@ -114,5 +116,5 @@
 
   ALLOCATE (fields, TableField, Nfields);
-  for (i = 0; i < Nfields; i++) {
+  for (int i = 0; i < Nfields; i++) {
     snprintf (keyword, 80, "TTYPE%d", i+1);
     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].ttype)) ESCAPE;
@@ -170,5 +172,5 @@
   // calling with an empty data array, data values are not actually copied (this is done
   // below after decompression)
-  for (i = 0; i < Nfields; i++) {
+  for (int i = 0; i < Nfields; i++) {
     if (!gfits_set_bintable_column (tgtheader, tgttable, fields[i].ttype, NULL, Ny)) ESCAPE;
   }
@@ -200,8 +202,7 @@
   gettimeofday (&startTimer, (void *) NULL);
 
-  off_t row;
-  for (row = 0; row < srcheader->Naxis[1]; row++) {
-
-    for (i = 0; i < Nfields; i++) {
+  for (off_t row = 0; row < srcheader->Naxis[1]; row++) {
+
+    for (int i = 0; i < Nfields; i++) {
 
       // gfits_uncompress_data can take values specific to the compression mode
@@ -218,7 +219,6 @@
     
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "u4: ");
-	for (k = 0; k < Nzdata; k++) {
+	for (int k = 0; k < Nzdata; k++) {
 	  fprintf (stderr, "%02hhx", zdata[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -250,7 +250,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "u3: ");
-	for (k = 0; k < Nzdata; k++) {
+	for (int k = 0; k < Nzdata; k++) {
 	  fprintf (stderr, "%02hhx", zdata[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -266,12 +265,11 @@
       gettimeofday (&startTimer, (void *) NULL);
   
-      int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
-      int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
+      unsigned long int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
+      unsigned long int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
       if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, Nraw_alloc, fields[i].pixsize)) ESCAPE;
 
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "u2: ");
-	for (k = 0; k < Nraw*fields[i].pixsize; k++) {
+	for (unsigned long int k = 0; k < Nraw*fields[i].pixsize; k++) {
 	  fprintf (stderr, "%02hhx", raw[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -299,7 +297,6 @@
   
       if (VERBOSE_DUMP) {
-	int k;
 	fprintf (stderr, "u1: ");
-	for (k = 0; k < Nraw*fields[i].pixsize; k++) {
+	for (unsigned long int k = 0; k < Nraw*fields[i].pixsize; k++) {
 	  fprintf (stderr, "%02hhx", raw[k]);
 	  if (k % 2) fprintf (stderr, " ");
@@ -356,6 +353,4 @@
 int gfits_distribute_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
 
-  off_t i;
-
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
 
@@ -367,8 +362,8 @@
 
   if (VERBOSE) fprintf (stderr, "distribute: ");
-  for (i = 0; i < Nrows; i++, tblbuffer += Nx) {
+  for (off_t i = 0; i < Nrows; i++, tblbuffer += Nx) {
     memcpy (tblbuffer, &raw[i*rowsize], rowsize);
 # if (VERBOSE)
-    int j; for (j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
+    for (int j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
 # endif
   }
@@ -379,6 +374,4 @@
 
 int gfits_distribute_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
-
-  off_t i, j, k;
 
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
@@ -391,5 +384,5 @@
   char *rawptr = raw;
 
-  for (k = 0; k < field->pixsize; k++) {
+  for (off_t k = 0; k < field->pixsize; k++) {
 # ifdef BYTE_SWAP      
     char *tblptr_start = &table->buffer[Nx*row_start + offset + (pixsize - k - 1)];
@@ -397,7 +390,7 @@
     char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
 # endif
-    for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
+    for (off_t i = 0; i < Nrows; i++, tblptr_start += Nx) {
       char *tblptr = tblptr_start;
-      for (j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
+      for (off_t j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
 	*tblptr = *rawptr;
       }
@@ -409,12 +402,10 @@
 int gfits_distribute_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
   
-  off_t i, j, k;
-  
   // we are copying NN rows into the column which starts at XX and has MM bytes per row
   
   off_t Nx = table->header->Naxis[0];
   
-  for (k = 0; k < field->pixsize; k++) {
-    for (i = 0; i < Nrows; i++) {
+  for (off_t k = 0; k < field->pixsize; k++) {
+    for (off_t i = 0; i < Nrows; i++) {
       int row = row_start + i;
       char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
@@ -424,5 +415,5 @@
       char *tblptr = &table->buffer[Nx*row + field->offset + k];
 # endif
-      for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
+      for (off_t j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
 	*tblptr = *rawptr;
       }
Index: trunk/Ohana/src/libfits/table/F_write_T.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_write_T.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_write_T.c	(revision 39457)
@@ -27,5 +27,5 @@
     myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
     myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
-    myAssert (myBlock->size >= table[0].datasize, "overflow");
+    myAssert (myBlock->size >= (size_t) table[0].datasize, "overflow");
   }
 # endif
Index: trunk/Ohana/src/libfits/table/F_write_TH.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_write_TH.c	(revision 39399)
+++ trunk/Ohana/src/libfits/table/F_write_TH.c	(revision 39457)
@@ -27,5 +27,5 @@
     myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
     myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
-    myAssert (myBlock->size >= header[0].datasize, "overflow");
+    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
   }
 # endif
Index: trunk/Ohana/src/libfits/test/imagecomp.c
===================================================================
--- trunk/Ohana/src/libfits/test/imagecomp.c	(revision 39399)
+++ trunk/Ohana/src/libfits/test/imagecomp.c	(revision 39457)
@@ -17,5 +17,5 @@
 static int NY = 10;
 
-int main (int argc, char **argv) {
+int main (void) {
   
   plan_tests (3*3*234);
@@ -196,6 +196,6 @@
   }     
 
-  int Ztile[2] = {NX, NY};
-  ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, (int *) &Ztile, zcmptype), "compressed image");
+  unsigned long int Ztile[2] = {NX, NY};
+  ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, (unsigned long int *) &Ztile, zcmptype), "compressed image");
   // ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, NULL, zcmptype), "compressed image");
   ok (gfits_uncompress_image (&outheader, &outmatrix, &ftable), "uncompressed image");
Index: trunk/Ohana/src/libfits/test/keywords.c
===================================================================
--- trunk/Ohana/src/libfits/test/keywords.c	(revision 39399)
+++ trunk/Ohana/src/libfits/test/keywords.c	(revision 39457)
@@ -15,5 +15,5 @@
   tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
 
-int main (int argc, char **argv) {
+int main (void) {
   
   plan_tests (14);
@@ -21,7 +21,4 @@
   diag ("libfits keyword tests");
 
-  int i, err;
-  double srcbuf[NSRC], tgtbuf[NTGT], outbuf[NOUT];
-  
   { 
     
@@ -96,6 +93,7 @@
     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
-    ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword");
-    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
+    // this is not ISO C99:
+    // ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword");
+    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
     // set one of each of the few numerical types (unsigned ints)
@@ -109,6 +107,6 @@
     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
-    ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword");
-    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
+    // ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword");
+    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
     ok (gfits_modify (&header, "D_SHORT", "%hd", 1, 0x20), "wrote a keyword");
@@ -229,7 +227,7 @@
     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
-    ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword");
-    ok (Kvalue == 0x100, "got the right value");
-    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
+    // ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword");
+    // ok (Kvalue == 0x100, "got the right value");
+    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
     // set one of each of the few numerical types (unsigned ints)
@@ -246,7 +244,7 @@
     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
-    ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword");
-    ok (Ulonglong == 0x100, "got the right value");
-    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
+    // ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword");
+    // ok (Ulonglong == 0x100, "got the right value");
+    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
 
     ok (gfits_scan (&header, "D_SHORT", "%hd", 1, &Ishort), "read a keyword");
Index: trunk/Ohana/src/libfits/test/ricetest.c
===================================================================
--- trunk/Ohana/src/libfits/test/ricetest.c	(revision 39399)
+++ trunk/Ohana/src/libfits/test/ricetest.c	(revision 39457)
@@ -1,4 +1,5 @@
 # include <ohana.h>
 # include <gfitsio.h>
+# include <gfits_compress.h>
 # include "tap_ohana.h"
 
@@ -6,5 +7,5 @@
 # define NBYTE 4*NPIX
 
-int main (int argc, char **argv) {
+int main (void) {
   
   plan_tests (45);
@@ -12,12 +13,11 @@
   diag ("libfits ricetest.c tests");
 
-  // buffers to store max array
-  char rawdata[NBYTE];
-  char cmpdata[NBYTE];
-  char outdata[NBYTE];
-
   // ok (1, "failure");
 
   if (1) { 
+    // buffers to store max array
+    char rawdata[NBYTE];
+    unsigned char outdata[NBYTE];
+    unsigned char cmpdata[NBYTE];
     char *rawvalue = (char *) rawdata;
     char *outvalue = (char *) outdata;
@@ -46,4 +46,9 @@
 
   if (1) { 
+    // buffers to store max array
+    char rawdata[NBYTE];
+    unsigned short outdata[NBYTE];
+    unsigned char cmpdata[NBYTE];
+
     short *rawvalue = (short *) rawdata;
     short *outvalue = (short *) outdata;
@@ -72,4 +77,9 @@
 
   if (1) { 
+    // buffers to store max array
+    char rawdata[NBYTE];
+    unsigned int outdata[NBYTE];
+    unsigned char cmpdata[NBYTE];
+
     int *rawvalue = (int *) rawdata;
     int *outvalue = (int *) outdata;
Index: trunk/Ohana/src/libfits/test/tablecomp.c
===================================================================
--- trunk/Ohana/src/libfits/test/tablecomp.c	(revision 39399)
+++ trunk/Ohana/src/libfits/test/tablecomp.c	(revision 39457)
@@ -10,7 +10,7 @@
 char *cmptype[] = {"NONE", "NONE_1", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", "AUTO", NULL};
 
-int main (int argc, char **argv) {
-  
-  plan_tests (668);
+int main (void) {
+  
+  plan_tests (668+428);
 
   diag ("libfits tablecomp.c tests");
@@ -28,4 +28,5 @@
     test_compress_empty (cmptype[i]);
     ok (ohana_memcheck (TRUE), "no memory corruption");
+    ohana_memdump (TRUE);
   }
 
@@ -89,4 +90,145 @@
     ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
 
+    if (0) { int ix, iy;
+      for (ix = 0; ix < 12; ix++) {
+	for (iy = 0; iy < 16; iy++) { 
+	  fprintf (stderr, "%x ", (int) cmptable.buffer[ix*16 + iy]);
+	}
+      }
+    }
+
+    Header rawheader;
+    FTable rawtable;
+    rawtable.header = &rawheader;
+    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
+
+    gfits_free_header (&cmpheader);
+    gfits_free_table (&cmptable);
+
+    outheader = &rawheader;
+    outtable  = &rawtable;
+  }
+
+  char type[16];
+  int Ncol;
+  off_t Nrow;
+
+  char    *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"),    "read byte    table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+  short   *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),   "read short   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+  int     *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),     "read int     table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+  int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+  float   *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),   "read float   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+  double  *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"),  "read double  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+
+  // count mismatched values
+  int NVAL_B_bad = 0;
+  int NVAL_I_bad = 0;
+  int NVAL_J_bad = 0;
+  int NVAL_K_bad = 0;
+  int NVAL_E_bad = 0;
+  int NVAL_D_bad = 0;
+
+  // for (i = 0; i < Nval; i++) {
+  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
+  // }
+
+  for (i = 0; i < Nval; i++) {
+    if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
+    if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++;
+    if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++;
+    if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++;
+    if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++;
+    if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++;
+  }
+
+  ok (!NVAL_B_bad, "byte    values match (input vs output)");
+  ok (!NVAL_I_bad, "short   values match (input vs output)");
+  ok (!NVAL_J_bad, "int     values match (input vs output)");
+  ok (!NVAL_K_bad, "int64_t values match (input vs output)");
+  ok (!NVAL_E_bad, "float   values match (input vs output)");
+  ok (!NVAL_D_bad, "double  values match (input vs output)");
+
+  free (VAL_B);
+  free (VAL_I);
+  free (VAL_J);
+  free (VAL_K);
+  free (VAL_E);
+  free (VAL_D);
+
+  free (VAL_B_t);
+  free (VAL_I_t);
+  free (VAL_J_t);
+  free (VAL_K_t);
+  free (VAL_E_t);
+  free (VAL_D_t);
+
+  gfits_free_header (&header);
+  gfits_free_table (&ftable);
+  if (zcmptype) {
+    gfits_free_header (outheader);
+    gfits_free_table (outtable);
+  }
+  return TRUE;
+}
+
+int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
+
+  Header header;
+  FTable ftable;
+
+  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
+  ok (gfits_init_header (&header), "inited the header");
+  ok (gfits_init_table (&ftable), "inited the table");
+
+  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
+
+  ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte",   "none", 1.0, 0.0), "defined byte column");
+  ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short",  "none", 1.0, 0.0), "defined short column");
+  ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int",    "none", 1.0, 0.0),  "defined int column");
+  ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long",   "none", 1.0, 0.0),  "defined long column");
+  ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float",  "degree", 1.0, 0.0),   "defined float column");
+  ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0),   "defined double column");
+  
+  // generate the output array that carries the data
+  ok (gfits_create_table (&header, &ftable), "created the basic table");
+
+  int Nval = 1000;
+  char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
+  short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
+  int     *VAL_J;  ALLOCATE (VAL_J, int,     Nval);
+  int64_t *VAL_K;  ALLOCATE (VAL_K, int64_t, Nval);
+  float   *VAL_E;  ALLOCATE (VAL_E, float,   Nval);
+  double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
+  
+  long A = time(NULL);
+  srand48(A);
+
+  int i;
+  for (i = 0; i < Nval; i++) {
+    VAL_B[i] =       0xff & lrand48();
+    VAL_I[i] =     0xffff & lrand48();
+    VAL_J[i] = 0xffffffff & lrand48();
+    VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48();
+    VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0);
+    VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0);
+  }     
+
+  // add the columns to the output array
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte   table column");
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short  table column");
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int    table column");
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long   table column");
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float  table column");
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column");
+
+  Header *outheader = &header;
+  FTable *outtable = &ftable;
+
+  if (zcmptype) {
+    Header cmpheader;
+    FTable cmptable;
+    cmptable.header = &cmpheader;
+    ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
+
     Header rawheader;
     FTable rawtable;
@@ -120,8 +262,4 @@
   int NVAL_D_bad = 0;
 
-  // for (i = 0; i < Nval; i++) {
-  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
-  // }
-
   for (i = 0; i < Nval; i++) {
     if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
@@ -140,4 +278,18 @@
   ok (!NVAL_D_bad, "double  values match (input vs output)");
 
+  free (VAL_B);
+  free (VAL_I);
+  free (VAL_J);
+  free (VAL_K);
+  free (VAL_E);
+  free (VAL_D);
+
+  free (VAL_B_t);
+  free (VAL_I_t);
+  free (VAL_J_t);
+  free (VAL_K_t);
+  free (VAL_E_t);
+  free (VAL_D_t);
+
   gfits_free_header (&header);
   gfits_free_table (&ftable);
@@ -149,5 +301,76 @@
 }
 
-int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
+int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
+
+  Header header;
+  FTable ftable;
+
+  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
+  ok (gfits_init_header (&header), "inited the header");
+  ok (gfits_init_table (&ftable), "inited the table");
+
+  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
+
+  ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
+  
+  // generate the output array that carries the data
+  ok (gfits_create_table (&header, &ftable), "created the basic table");
+
+  int Nval = 1000;
+  short *SEQ;  ALLOCATE (SEQ, short,  Nval);
+  
+  int i;
+  for (i = 0; i < Nval; i++) {
+    SEQ[i] = i;
+  }     
+
+  // add the columns to the output array
+  ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
+
+  Header *outheader = &header;
+  FTable *outtable = &ftable;
+
+  if (zcmptype) {
+    Header cmpheader;
+    FTable cmptable;
+    cmptable.header = &cmpheader;
+    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
+
+    Header rawheader;
+    FTable rawtable;
+    rawtable.header = &rawheader;
+    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
+    
+    gfits_free_header (&cmpheader);
+    gfits_free_table (&cmptable);
+
+    outheader = &rawheader;
+    outtable  = &rawtable;
+  }
+
+  char type[16];
+  int Ncol;
+  off_t Nrow;
+
+  short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+
+  // count mismatched values
+  int Nseq = 0;
+  for (i = 0; i < Nval; i++) {
+    if (SEQ[i] != SEQ_t[i]) Nseq++;
+  }
+
+  ok (!Nseq,   "short  values match (input vs output)");
+
+  gfits_free_header (&header);
+  gfits_free_table (&ftable);
+  if (zcmptype) {
+    gfits_free_header (outheader);
+    gfits_free_table (outtable);
+  }
+  return TRUE;
+}
+
+int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
 
   Header header;
@@ -170,5 +393,5 @@
   ok (gfits_create_table (&header, &ftable), "created the basic table");
 
-  int Nval = 1000;
+  int Nval = 0;
   char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
   short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
@@ -178,15 +401,12 @@
   double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
   
-  long A = time(NULL);
-  srand48(A);
-
   int i;
   for (i = 0; i < Nval; i++) {
-    VAL_B[i] =       0xff & lrand48();
-    VAL_I[i] =     0xffff & lrand48();
-    VAL_J[i] = 0xffffffff & lrand48();
-    VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48();
-    VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0);
-    VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0);
+    VAL_B[i] = (i % 255) - 128;
+    VAL_I[i] = i;
+    VAL_J[i] = 10000*i + 100*i;
+    VAL_K[i] = 10000*i + 330*i;
+    VAL_E[i] = 0.1*i;
+    VAL_D[i] = 1.001*i;
   }     
 
@@ -206,5 +426,5 @@
     FTable cmptable;
     cmptable.header = &cmpheader;
-    ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
+    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
 
     Header rawheader;
@@ -239,4 +459,8 @@
   int NVAL_D_bad = 0;
 
+  // for (i = 0; i < Nval; i++) {
+  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
+  // }
+
   for (i = 0; i < Nval; i++) {
     if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
@@ -255,4 +479,18 @@
   ok (!NVAL_D_bad, "double  values match (input vs output)");
 
+  free (VAL_B);
+  free (VAL_I);
+  free (VAL_J);
+  free (VAL_K);
+  free (VAL_E);
+  free (VAL_D);
+
+  free (VAL_B_t);
+  free (VAL_I_t);
+  free (VAL_J_t);
+  free (VAL_K_t);
+  free (VAL_E_t);
+  free (VAL_D_t);
+
   gfits_free_header (&header);
   gfits_free_table (&ftable);
@@ -264,190 +502,3 @@
 }
 
-int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
-
-  Header header;
-  FTable ftable;
-
-  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
-  ok (gfits_init_header (&header), "inited the header");
-  ok (gfits_init_table (&ftable), "inited the table");
-
-  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
-
-  ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
-  
-  // generate the output array that carries the data
-  ok (gfits_create_table (&header, &ftable), "created the basic table");
-
-  int Nval = 1000;
-  short *SEQ;  ALLOCATE (SEQ, short,  Nval);
-  
-  int i;
-  for (i = 0; i < Nval; i++) {
-    SEQ[i] = i;
-  }     
-
-  // add the columns to the output array
-  ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
-
-  Header *outheader = &header;
-  FTable *outtable = &ftable;
-
-  if (zcmptype) {
-    Header cmpheader;
-    FTable cmptable;
-    cmptable.header = &cmpheader;
-    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
-
-    Header rawheader;
-    FTable rawtable;
-    rawtable.header = &rawheader;
-    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
-    
-    gfits_free_header (&cmpheader);
-    gfits_free_table (&cmptable);
-
-    outheader = &rawheader;
-    outtable  = &rawtable;
-  }
-
-  char type[16];
-  int Ncol;
-  off_t Nrow;
-
-  short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-
-  // count mismatched values
-  int Nseq = 0;
-  for (i = 0; i < Nval; i++) {
-    if (SEQ[i] != SEQ_t[i]) Nseq++;
-  }
-
-  ok (!Nseq,   "short  values match (input vs output)");
-
-  gfits_free_header (&header);
-  gfits_free_table (&ftable);
-  if (zcmptype) {
-    gfits_free_header (outheader);
-    gfits_free_table (outtable);
-  }
-  return TRUE;
-}
-
-int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
-
-  Header header;
-  FTable ftable;
-
-  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
-  ok (gfits_init_header (&header), "inited the header");
-  ok (gfits_init_table (&ftable), "inited the table");
-
-  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
-
-  ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte",   "none", 1.0, 0.0), "defined byte column");
-  ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short",  "none", 1.0, 0.0), "defined short column");
-  ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int",    "none", 1.0, 0.0),  "defined int column");
-  ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long",   "none", 1.0, 0.0),  "defined long column");
-  ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float",  "degree", 1.0, 0.0),   "defined float column");
-  ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0),   "defined double column");
-  
-  // generate the output array that carries the data
-  ok (gfits_create_table (&header, &ftable), "created the basic table");
-
-  int Nval = 0;
-  char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
-  short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
-  int     *VAL_J;  ALLOCATE (VAL_J, int,     Nval);
-  int64_t *VAL_K;  ALLOCATE (VAL_K, int64_t, Nval);
-  float   *VAL_E;  ALLOCATE (VAL_E, float,   Nval);
-  double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
-  
-  int i;
-  for (i = 0; i < Nval; i++) {
-    VAL_B[i] = (i % 255) - 128;
-    VAL_I[i] = i;
-    VAL_J[i] = 10000*i + 100*i;
-    VAL_K[i] = 10000*i + 330*i;
-    VAL_E[i] = 0.1*i;
-    VAL_D[i] = 1.001*i;
-  }     
-
-  // add the columns to the output array
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte   table column");
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short  table column");
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int    table column");
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long   table column");
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float  table column");
-  ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column");
-
-  Header *outheader = &header;
-  FTable *outtable = &ftable;
-
-  if (zcmptype) {
-    Header cmpheader;
-    FTable cmptable;
-    cmptable.header = &cmpheader;
-    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
-
-    Header rawheader;
-    FTable rawtable;
-    rawtable.header = &rawheader;
-    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
-    
-    gfits_free_header (&cmpheader);
-    gfits_free_table (&cmptable);
-
-    outheader = &rawheader;
-    outtable  = &rawtable;
-  }
-
-  char type[16];
-  int Ncol;
-  off_t Nrow;
-
-  char    *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"),    "read byte    table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-  short   *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),   "read short   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-  int     *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),     "read int     table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-  int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-  float   *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),   "read float   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-  double  *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"),  "read double  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
-
-  // count mismatched values
-  int NVAL_B_bad = 0;
-  int NVAL_I_bad = 0;
-  int NVAL_J_bad = 0;
-  int NVAL_K_bad = 0;
-  int NVAL_E_bad = 0;
-  int NVAL_D_bad = 0;
-
-  // for (i = 0; i < Nval; i++) {
-  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
-  // }
-
-  for (i = 0; i < Nval; i++) {
-    if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
-    if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++;
-    if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++;
-    if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++;
-    if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++;
-    if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++;
-  }
-
-  ok (!NVAL_B_bad, "byte    values match (input vs output)");
-  ok (!NVAL_I_bad, "short   values match (input vs output)");
-  ok (!NVAL_J_bad, "int     values match (input vs output)");
-  ok (!NVAL_K_bad, "int64_t values match (input vs output)");
-  ok (!NVAL_E_bad, "float   values match (input vs output)");
-  ok (!NVAL_D_bad, "double  values match (input vs output)");
-
-  gfits_free_header (&header);
-  gfits_free_table (&ftable);
-  if (zcmptype) {
-    gfits_free_header (outheader);
-    gfits_free_table (outtable);
-  }
-  return TRUE;
-}
-
-
+
Index: trunk/Ohana/src/libfits/test/zlib.c
===================================================================
--- trunk/Ohana/src/libfits/test/zlib.c	(revision 39399)
+++ trunk/Ohana/src/libfits/test/zlib.c	(revision 39457)
@@ -16,5 +16,5 @@
   tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
 
-int main (int argc, char **argv) {
+int main (void) {
   
   plan_tests (14);
@@ -30,7 +30,7 @@
   { 
     z_stream zdn;
-    zdn.next_in = (char *) srcbuf;
+    zdn.next_in = (unsigned char *) srcbuf;
     zdn.avail_in = NSRC * sizeof(double);
-    zdn.next_out = (char *) tgtbuf;
+    zdn.next_out = (unsigned char *) tgtbuf;
     zdn.avail_out = NTGT * sizeof(double);
   
@@ -83,7 +83,7 @@
   {
     z_stream zup;
-    zup.next_in = (char *) tgtbuf;
+    zup.next_in = (unsigned char *) tgtbuf;
     zup.avail_in = NTGT * sizeof(double);
-    zup.next_out = (char *) outbuf;
+    zup.next_out = (unsigned char *) outbuf;
     zup.avail_out = NOUT * sizeof(double);
   
@@ -120,7 +120,7 @@
   { 
     z_stream zdn;
-    zdn.next_in = (char *) srcbuf;
+    zdn.next_in = (unsigned char *) srcbuf;
     zdn.avail_in = NSRC * sizeof(double);
-    zdn.next_out = (char *) tgtbuf;
+    zdn.next_out = (unsigned char *) tgtbuf;
     zdn.avail_out = NTGT * sizeof(double);
   
@@ -174,7 +174,7 @@
   {
     z_stream zup;
-    zup.next_in = (char *) tgtbuf;
+    zup.next_in = (unsigned char *) tgtbuf;
     zup.avail_in = NTGT * sizeof(double);
-    zup.next_out = (char *) outbuf;
+    zup.next_out = (unsigned char *) outbuf;
     zup.avail_out = NOUT * sizeof(double);
   
