summaryrefslogtreecommitdiffstats
path: root/hl/test/test_image.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-03-05 14:19:02 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-03-05 14:19:02 (GMT)
commit6a2c50b10af4bc88e4b1a1a95cb3f9be813d61f2 (patch)
tree2df899df87c4b55c54faedeceb036b31340ee62f /hl/test/test_image.c
parent7619eb4b18d1d90db694bb96f2b26a5680150a89 (diff)
downloadhdf5-6a2c50b10af4bc88e4b1a1a95cb3f9be813d61f2.zip
hdf5-6a2c50b10af4bc88e4b1a1a95cb3f9be813d61f2.tar.gz
hdf5-6a2c50b10af4bc88e4b1a1a95cb3f9be813d61f2.tar.bz2
[svn-r22025] Cleanup compiler warnings.
Add HD prefix to tools library based tests. Cleaned allocation/free in tests. Tested: local linux/ h5committetest
Diffstat (limited to 'hl/test/test_image.c')
-rw-r--r--hl/test/test_image.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 29799e5..2e1e465 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -527,17 +527,17 @@ static int test_generate(void)
*/
if ( srcdir )
{
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
+ HDstrcpy(data_file, srcdir);
+ HDstrcat(data_file, "/");
}
- strcat(data_file,DATA_FILE4);
+ HDstrcat(data_file,DATA_FILE4);
/*-------------------------------------------------------------------------
* read data; the file data format is described below
*-------------------------------------------------------------------------
*/
- f = fopen( data_file, "r" ) ;
+ f = HDfopen( data_file, "r" ) ;
if ( f == NULL )
{
printf( "Could not find file %s. Try set $srcdir \n", data_file );
@@ -584,15 +584,15 @@ static int test_generate(void)
fscanf( f, "%d %d %d", &imax, &jmax, &kmax );
fscanf( f, "%f %f %f", &valex, &xmin, &xmax );
- data = (float*) malloc ( imax * jmax * kmax * sizeof( float ));
- image_data = (unsigned char*) malloc ( imax * jmax * kmax * sizeof( unsigned char ));
+ data = (float*) HDmalloc ( imax * jmax * kmax * sizeof( float ));
+ image_data = (unsigned char*) HDmalloc ( imax * jmax * kmax * sizeof( unsigned char ));
for ( i = 0; i < imax * jmax * kmax; i++ )
{
fscanf( f, "%f ", &value );
data[i] = value;
}
- fclose( f );
+ HDfclose( f );
/*-------------------------------------------------------------------------
* transform the data from floating point to unsigned char
@@ -731,20 +731,20 @@ static int read_data( const char* fname, /*IN*/
* compose the name of the file to open, using "srcdir", if appropriate
*-------------------------------------------------------------------------
*/
- strcpy(data_file, "");
+ HDstrcpy(data_file, "");
if (srcdir)
{
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
+ HDstrcpy(data_file, srcdir);
+ HDstrcat(data_file, "/");
}
- strcat(data_file,fname);
+ HDstrcat(data_file,fname);
/*-------------------------------------------------------------------------
* read
*-------------------------------------------------------------------------
*/
- f = fopen(data_file, "r");
+ f = HDfopen(data_file, "r");
if ( f == NULL )
{
printf( "Could not open file %s. Try set $srcdir \n", data_file );
@@ -763,18 +763,18 @@ static int read_data( const char* fname, /*IN*/
if ( image_data )
{
- free( image_data );
+ HDfree( image_data );
image_data=NULL;
}
- image_data = (unsigned char*) malloc (w * h * color_planes * sizeof( unsigned char ));
+ image_data = (unsigned char*) HDmalloc (w * h * color_planes * sizeof( unsigned char ));
for (i = 0; i < h * w * color_planes ; i++)
{
fscanf( f, "%d",&n );
image_data[i] = (unsigned char)n;
}
- fclose(f);
+ HDfclose(f);
return 1;
@@ -819,59 +819,59 @@ static int read_palette(const char* fname,
* compose the name of the file to open, using "srcdir", if appropriate
*-------------------------------------------------------------------------
*/
- strcpy(data_file, "");
+ HDstrcpy(data_file, "");
if (srcdir)
{
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
+ HDstrcpy(data_file, srcdir);
+ HDstrcat(data_file, "/");
}
- strcat(data_file,fname);
+ HDstrcat(data_file,fname);
/* ensure the given palette is valid */
if (!palette)
return -1;
/* open the input file */
- if (!(file = fopen(data_file, "r")))
+ if (!(file = HDfopen(data_file, "r")))
{
printf( "Could not open file %s. Try set $srcdir \n", data_file );
return -1;
}
/* read the file ident string */
- if (fgets(buffer, sizeof(buffer), file) == NULL)
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL)
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* ensure it matches the palette file ident string */
- if ( strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
- strncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 )
+ if ( HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 )
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* read the version string */
- if (fgets(buffer, sizeof(buffer), file) == NULL)
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL)
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* ensure it matches the palette file version string */
- if ( strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
- strncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 )
+ if ( HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 )
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* read the number of colors */
- if (fgets(buffer, sizeof(buffer), file) == NULL)
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL)
{
- fclose(file);
+ HDfclose(file);
return -1;
}
@@ -880,22 +880,22 @@ static int read_palette(const char* fname,
check for missing version or number of colors
in this case it reads the first entry
*/
- if ( strlen( buffer ) > 4 )
+ if ( HDstrlen( buffer ) > 4 )
{
- fclose(file);
+ HDfclose(file);
return -1;
}
if (sscanf(buffer, "%u", &nentries) != 1)
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* ensure there are a sensible number of colors in the palette */
if ((nentries > 256) || (nentries > palette_size))
{
- fclose(file);
+ HDfclose(file);
return(-1);
}
@@ -905,7 +905,7 @@ static int read_palette(const char* fname,
/* extract the red, green and blue color components. */
if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3)
{
- fclose(file);
+ HDfclose(file);
return -1;
}
/* store this palette entry */
@@ -915,7 +915,7 @@ static int read_palette(const char* fname,
}
/* close file */
- fclose(file);
+ HDfclose(file);
return nentries;
}