summaryrefslogtreecommitdiffstats
path: root/hl/tools
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-01-30 16:43:40 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-01-30 16:43:40 (GMT)
commitd1f2eff23148da5e39463bd351be51767755b1c1 (patch)
treea52f4d1051f339a18e7e52a74a1af02ddf1f8f37 /hl/tools
parent1255363e9be3280108a351d97237de13755d6368 (diff)
parenta67c238feef1487814b02132bfd7961f22d9d6eb (diff)
downloadhdf5-d1f2eff23148da5e39463bd351be51767755b1c1.zip
hdf5-d1f2eff23148da5e39463bd351be51767755b1c1.tar.gz
hdf5-d1f2eff23148da5e39463bd351be51767755b1c1.tar.bz2
Merge pull request #2328 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:develop_minor to develop
* commit 'a67c238feef1487814b02132bfd7961f22d9d6eb': Cleaned up remaining warnings in high-level library.
Diffstat (limited to 'hl/tools')
-rw-r--r--hl/tools/gif2h5/decompress.c23
-rw-r--r--hl/tools/gif2h5/hdfgifwr.c96
2 files changed, 73 insertions, 46 deletions
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c
index 8cd8a8e..129fa60 100644
--- a/hl/tools/gif2h5/decompress.c
+++ b/hl/tools/gif2h5/decompress.c
@@ -57,12 +57,12 @@ GIFBYTE *Raster; /* The raster data stream, unblocked *
/* The hash table used by the decompressor */
-int Prefix[4096];
-int Suffix[4096];
+int *Prefix;
+int *Suffix;
/* An output array used by the decompressor */
-int OutCode[1025];
+int *OutCode;
/* The color map, read from the GIF header */
@@ -159,6 +159,19 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
{
int i;
+ if (!(Prefix = calloc(4096, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+ if (!(Suffix = calloc(4096, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+ if (!(OutCode = calloc(1024, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+
XC = 0;
YC = 0;
Pass = 0;
@@ -309,5 +322,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
Code = ReadCode();
}
+ free(Prefix);
+ free(Suffix);
+ free(OutCode);
+
return Image;
}
diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c
index ed3e9e9..d44ff7a 100644
--- a/hl/tools/gif2h5/hdfgifwr.c
+++ b/hl/tools/gif2h5/hdfgifwr.c
@@ -69,45 +69,6 @@ static void char_init(), char_out(), flush_char();
static byte pc2nc[256];
-/*************************************************************/
-int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap,
- byte *gmap, byte *bmap, byte *pc2ncmap, int numcols,
- int colorstyle, int BitsPerPixel)
-{
- int InitCodeSize;
- int i;
- byte *pic8 = pic;
-
- /* Shut compiler up... */
- ptype=ptype;
- rmap=rmap;
- gmap=gmap;
- bmap=bmap;
- numcols=numcols;
- colorstyle=colorstyle;
-
- for (i = 0; i < 256; i++) {
- pc2nc[i] = pc2ncmap[i];
- }
-
- if (BitsPerPixel <= 1)
- InitCodeSize = 2;
- else
- InitCodeSize = BitsPerPixel;
-
- if (!fp) {
- fprintf(stderr, "WriteGIF: file not open for writing\n" );
- return (1);
- }
-
- compress(InitCodeSize+1, fp, pic8, w*h);
-
- if (ferror(fp))
- return -1;
-
- return 0 ;
-}
-
/***********************************************************************/
static unsigned long cur_accum = 0;
static int cur_bits = 0;
@@ -123,8 +84,8 @@ static int maxbits = XV_BITS; /* user settable max # bits/code */
static int maxcode; /* maximum code, given n_bits */
static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */
-static count_int htab [HSIZE];
-static unsigned short codetab [HSIZE];
+static count_int *htab;
+static unsigned short *codetab;
#define HashTabOf(i) htab[i]
#define CodeTabOf(i) codetab[i]
@@ -173,6 +134,57 @@ static FILE *g_outfile;
static int ClearCode;
static int EOFCode;
+/*************************************************************/
+int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap,
+ byte *gmap, byte *bmap, byte *pc2ncmap, int numcols,
+ int colorstyle, int BitsPerPixel)
+{
+ int InitCodeSize;
+ int i;
+ byte *pic8 = pic;
+
+ if (!(htab = calloc(HSIZE, sizeof(count_int)))) {
+ fprintf(stderr, "Out of memory");
+ return 1;
+ }
+ if (!(codetab = calloc(HSIZE, sizeof(unsigned short)))) {
+ fprintf(stderr, "Out of memory");
+ return 1;
+ }
+
+ /* Shut compiler up... */
+ ptype=ptype;
+ rmap=rmap;
+ gmap=gmap;
+ bmap=bmap;
+ numcols=numcols;
+ colorstyle=colorstyle;
+
+ for (i = 0; i < 256; i++) {
+ pc2nc[i] = pc2ncmap[i];
+ }
+
+ if (BitsPerPixel <= 1)
+ InitCodeSize = 2;
+ else
+ InitCodeSize = BitsPerPixel;
+
+ if (!fp) {
+ fprintf(stderr, "WriteGIF: file not open for writing\n");
+ return 1;
+ }
+
+ compress(InitCodeSize+1, fp, pic8, w*h);
+
+ free(htab);
+ free(codetab);
+
+ if (ferror(fp))
+ return -1;
+
+ return 0 ;
+}
+
/********************************************************/
static void compress(int init_bits, FILE *outfile, byte *data, int len)
{
@@ -194,8 +206,6 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len)
/* initialize 'compress' globals */
maxbits = XV_BITS;
maxmaxcode = 1<<XV_BITS;
- memset(htab, 0, sizeof(htab));
- memset(codetab, 0, sizeof(codetab));
hsize = HSIZE;
free_ent = 0;
clear_flg = 0;