summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-06-18 20:22:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-06-18 20:22:10 (GMT)
commitd41b9fffdfca2e97c36bc0ad0899fbb7b055f926 (patch)
tree51ed39b08a41a4f6947af07630eb40dfdb013d87 /tools/lib
parentfcaf572430a8eda3f6519bd21311ef7a8e3c3c1f (diff)
downloadhdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.zip
hdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.tar.gz
hdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.tar.bz2
[svn-r4012] Purpose:
Clean up compiler warnings. Description: Just code neatening mostly, some casts, etc. Platforms tested: FreeBSD 4.3 (hawkwind)
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c106
-rw-r--r--tools/lib/h5tools.h2
-rw-r--r--tools/lib/h5tools_str.c140
-rw-r--r--tools/lib/h5tools_str.h2
-rw-r--r--tools/lib/h5tools_utils.c189
5 files changed, 222 insertions, 217 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 2341c7f..fc2d034 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -90,8 +90,8 @@ h5tools_close(void)
{
if (h5tools_init_g) {
if (rawdatastream && rawdatastream != stdout) {
- if (fclose(rawdatastream))
- perror("closing rawdatastream");
+ if (HDfclose(rawdatastream))
+ HDperror("closing rawdatastream");
else
rawdatastream = NULL;
}
@@ -204,7 +204,7 @@ h5tools_fopen(const char *fname, char *drivername, size_t drivername_size)
/* Save the driver name */
if (drivername && drivername_size) {
if (fid >= 0) {
- strncpy(drivername, driver[drivernum].name, drivername_size);
+ HDstrncpy(drivername, driver[drivernum].name, drivername_size);
drivername[drivername_size - 1] = '\0';
} else {
/*no file opened*/
@@ -271,13 +271,13 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info,
if (!ctx->need_prefix)
return;
- memset(&prefix, 0, sizeof(h5tools_str_t));
+ HDmemset(&prefix, 0, sizeof(h5tools_str_t));
/* Terminate previous line, if any */
if (ctx->cur_column) {
- fputs(OPT(info->line_suf, ""), stream);
- putc('\n', stream);
- fputs(OPT(info->line_sep, ""), stream);
+ HDfputs(OPT(info->line_suf, ""), stream);
+ HDputc('\n', stream);
+ HDfputs(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -298,16 +298,16 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info,
}
if (elmtno == 0 && secnum == 0 && info->line_1st)
- fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
else if (secnum && info->line_cont)
- fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
else
- fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++){
- fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
@@ -366,7 +366,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*to the ctx->size_last_dim. */
/* Setup */
- memset(&buffer, 0, sizeof(h5tools_str_t));
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
size = H5Tget_size(type);
if (info->line_ncols > 0)
@@ -390,8 +390,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if (info->line_multi_new == 1 &&
(ctx->cur_column + h5tools_ncols(s) +
- strlen(OPT(info->elmt_suf2, " ")) +
- strlen(OPT(info->line_suf, ""))) > ncols) {
+ HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols) {
if (ctx->prev_multiline) {
/*
* ... and the previous element also occupied more than one
@@ -399,8 +399,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
ctx->need_prefix = TRUE;
} else if ((ctx->prev_prefix_len + h5tools_ncols(s) +
- strlen(OPT(info->elmt_suf2, " ")) +
- strlen(OPT(info->line_suf, ""))) <= ncols) {
+ HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
/*
* ...but *could* fit on one line otherwise, then we
* should end the current line and start this element on its
@@ -432,8 +432,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if (info->line_multi_new == 1 && ctx->prev_multiline &&
(ctx->cur_column + h5tools_ncols(s) +
- strlen(OPT(info->elmt_suf2, " ")) +
- strlen(OPT(info->line_suf, ""))) > ncols)
+ HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
/*
@@ -463,8 +463,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if ((!info->skip_first || i) &&
(ctx->cur_column + strlen(section) +
- strlen(OPT(info->elmt_suf2, " ")) +
- strlen(OPT(info->line_suf, ""))) > ncols)
+ HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
@@ -477,13 +477,13 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
h5tools_simple_prefix(stream, info, ctx, i, secnum);
} else if ((i || ctx->continuation) && secnum == 0) {
- fputs(OPT(info->elmt_suf2, " "), stream);
- ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
+ HDfputs(OPT(info->elmt_suf2, " "), stream);
+ ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- fputs(section, stream);
- ctx->cur_column += strlen(section);
+ HDfputs(section, stream);
+ ctx->cur_column += HDstrlen(section);
}
ctx->prev_multiline = multiline;
@@ -513,7 +513,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
{
herr_t ret; /*the value to return */
hid_t f_space; /*file data space */
- hsize_t elmtno, i; /*counters */
+ hsize_t i; /*counters */
hssize_t zero = 0; /*vector of zeros */
unsigned int flags; /*buffer extent flags */
hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/
@@ -542,7 +542,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- memset(&ctx, 0, sizeof(ctx));
+ HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = indentlevel;
ctx.need_prefix = 1;
ctx.ndims = H5Sget_simple_extent_ndims(f_space);
@@ -604,7 +604,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
}
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = malloc((size_t)sm_nelmts * p_type_nbytes);
+ sm_buf = HDmalloc((size_t)sm_nelmts * p_type_nbytes);
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL);
@@ -613,7 +613,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
H5Sclose(f_space);
H5Sclose(sm_space);
- free(sm_buf);
+ HDfree(sm_buf);
return FAIL;
}
@@ -629,15 +629,15 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
h5tools_dump_simple_data(stream, info, dset, &ctx, flags, sm_nelmts,
p_type, sm_buf);
- free(sm_buf);
+ HDfree(sm_buf);
ctx.continuation++;
}
/* Terminate the output */
if (ctx.cur_column) {
- fputs(OPT(info->line_suf, ""), stream);
- putc('\n', stream);
- fputs(OPT(info->line_sep, ""), stream);
+ HDfputs(OPT(info->line_suf, ""), stream);
+ HDputc('\n', stream);
+ HDfputs(OPT(info->line_sep, ""), stream);
}
ret = SUCCEED;
@@ -707,7 +707,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- memset(&ctx, 0, sizeof(ctx));
+ HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = indentlevel;
ctx.need_prefix = 1;
ctx.ndims = H5Sget_simple_extent_ndims(f_space);
@@ -757,13 +757,13 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
}
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = malloc((size_t)sm_nbytes);
+ sm_buf = HDmalloc((size_t)sm_nbytes);
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
/* The stripmine loop */
- memset(hs_offset, 0, sizeof hs_offset);
- memset(zero, 0, sizeof zero);
+ HDmemset(hs_offset, 0, sizeof hs_offset);
+ HDmemset(zero, 0, sizeof zero);
for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
/* Calculate the hyperslab size */
@@ -788,7 +788,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
H5Sclose(f_space);
H5Sclose(sm_space);
- free(sm_buf);
+ HDfree(sm_buf);
return FAIL;
}
@@ -818,14 +818,14 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
/* Terminate the output */
if (ctx.cur_column) {
- fputs(OPT(info->line_suf, ""), stream);
- putc('\n', stream);
- fputs(OPT(info->line_sep, ""), stream);
+ HDfputs(OPT(info->line_suf, ""), stream);
+ HDputc('\n', stream);
+ HDfputs(OPT(info->line_sep, ""), stream);
}
H5Sclose(sm_space);
H5Sclose(f_space);
- free(sm_buf);
+ HDfree(sm_buf);
return SUCCEED;
}
@@ -859,7 +859,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- memset(&ctx, 0, sizeof(ctx));
+ HDmemset(&ctx, 0, sizeof(ctx));
ctx.ndims = H5Sget_simple_extent_ndims(space);
if ((size_t)ctx.ndims > NELMTS(ctx.p_min_idx))
@@ -888,9 +888,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
/* Terminate the output */
if (ctx.cur_column) {
- fputs(OPT(info->line_suf, ""), stream);
- putc('\n', stream);
- fputs(OPT(info->line_sep, ""), stream);
+ HDfputs(OPT(info->line_suf, ""), stream);
+ HDputc('\n', stream);
+ HDfputs(OPT(info->line_sep, ""), stream);
}
return SUCCEED;
@@ -989,8 +989,8 @@ h5tools_fixtype(hid_t f_type)
*/
nmembs = H5Tget_nmembers(f_type);
assert(nmembs > 0);
- memb = calloc((size_t)nmembs, sizeof(hid_t));
- name = calloc((size_t)nmembs, sizeof(char *));
+ memb = HDcalloc((size_t)nmembs, sizeof(hid_t));
+ name = HDcalloc((size_t)nmembs, sizeof(char *));
for (i = 0, size = 0; i < nmembs; i++) {
/* Get the member type and fix it */
@@ -1087,18 +1087,18 @@ h5tools_fixtype(hid_t f_type)
done:
/* Clean up temp buffers */
if (memb && name) {
- register int j;
+ int j;
for (j = 0; j < nmembs; j++) {
if (memb[j] >= 0)
H5Tclose(memb[j]);
if (name[j])
- free(name[j]);
+ HDfree(name[j]);
}
- free(memb);
- free(name);
+ HDfree(memb);
+ HDfree(name);
}
return m_type;
@@ -1151,7 +1151,7 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type,
stream = stdout;
if (!info) {
- memset(&info_dflt, 0, sizeof info_dflt);
+ HDmemset(&info_dflt, 0, sizeof info_dflt);
info = &info_dflt;
}
@@ -1221,7 +1221,7 @@ h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type,
stream = stdout;
if (!info) {
- memset(&info_dflt, 0, sizeof(info_dflt));
+ HDmemset(&info_dflt, 0, sizeof(info_dflt));
info = &info_dflt;
}
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 6a6f859..b4e23d6 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -404,7 +404,7 @@ typedef struct h5tools_context_t {
/* a structure to hold the subsetting particulars for a dataset */
struct subset_t {
- hsize_t *start;
+ hssize_t *start;
hsize_t *stride;
hsize_t *count;
hsize_t *block;
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index e594ebd..3922640 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -54,8 +54,8 @@ void
h5tools_str_close(h5tools_str_t *str)
{
if (str && str->nalloc) {
- free(str->s);
- memset(str, 0, sizeof(h5tools_str_t));
+ HDfree(str->s);
+ HDmemset(str, 0, sizeof(h5tools_str_t));
}
}
@@ -109,7 +109,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
/* Make sure we have some memory into which to print */
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = malloc(str->nalloc);
+ str->s = HDmalloc(str->nalloc);
assert(str->s);
str->s[0] = '\0';
str->len = 0;
@@ -127,7 +127,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
/* Try again with twice as much space */
str->nalloc *= 2;
- str->s = realloc(str->s, str->nalloc);
+ str->s = HDrealloc(str->s, str->nalloc);
assert(str->s);
}
@@ -158,7 +158,7 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/)
{
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = malloc(str->nalloc);
+ str->s = HDmalloc(str->nalloc);
assert(str->s);
}
@@ -220,20 +220,20 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
char _temp[1024], *temp = _temp;
/* If the format string is simply "%s" then don't bother doing anything */
- if (!strcmp(fmt, "%s"))
+ if (!HDstrcmp(fmt, "%s"))
return str->s;
/*
* Save the input value if there is a `%' anywhere in FMT. Otherwise
* don't bother because we don't need a temporary copy.
*/
- if (strchr(fmt, '%')) {
+ if (HDstrchr(fmt, '%')) {
if (str->len - start + 1 > sizeof(_temp)) {
- temp = malloc(str->len-start + 1);
+ temp = HDmalloc(str->len-start + 1);
assert(temp);
}
- strcpy(temp, str->s + start);
+ HDstrcpy(temp, str->s + start);
}
/* Reset the output string and append a formatted version */
@@ -242,7 +242,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
/* Free the temp buffer if we allocated one */
if (temp != _temp)
- free(temp);
+ HDfree(temp);
return str->s;
}
@@ -347,7 +347,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata = malloc((size_t)alloc_size);
+ ptdata = HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata);
@@ -370,7 +370,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
h5tools_str_append(str, ")");
}
- free(ptdata);
+ HDfree(ptdata);
}
/* Print point information */
@@ -379,7 +379,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
alloc_size = npoints * ndims * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata = malloc((size_t)alloc_size);
+ ptdata = HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t);
H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata);
@@ -397,7 +397,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
h5tools_str_append(str, ")");
}
- free(ptdata);
+ HDfree(ptdata);
}
h5tools_str_append(str, "}");
@@ -450,7 +450,7 @@ h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch)
h5tools_str_append(str, "\\t");
break;
default:
- if (isprint(ch))
+ if (HDisprint(ch))
h5tools_str_append(str, "%c", (char)ch);
else
h5tools_str_append(str, "\\%03o", ch);
@@ -533,14 +533,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
for (i = 0; i < n; i++)
h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
} else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- memcpy(&tempfloat, vp, sizeof(float));
+ HDmemcpy(&tempfloat, vp, sizeof(float));
h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
} else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- memcpy(&tempdouble, vp, sizeof(double));
+ HDmemcpy(&tempdouble, vp, sizeof(double));
h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
} else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, *ucp_vp);
+ h5tools_print_char(str, info, (unsigned char)*ucp_vp);
} else if (H5T_STRING == H5Tget_class(type)) {
unsigned int i;
@@ -578,7 +578,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
}
/* Print the character */
- h5tools_print_char(str, info, ucp_vp[i]);
+ h5tools_print_char(str, info, (unsigned char)ucp_vp[i]);
/* Print the repeat count */
if (info->str_repeat && j > info->str_repeat) {
@@ -600,53 +600,53 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
/*empty string*/
h5tools_str_append(str, "\"\"");
} else if (H5Tequal(type, H5T_NATIVE_INT)) {
- memcpy(&tempint, vp, sizeof(int));
+ HDmemcpy(&tempint, vp, sizeof(int));
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
} else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- memcpy(&tempuint, vp, sizeof(unsigned int));
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
} else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp);
} else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp);
} else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- memcpy(&tempshort, vp, sizeof(short));
+ HDmemcpy(&tempshort, vp, sizeof(short));
h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
} else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- memcpy(&tempushort, vp, sizeof(unsigned short));
+ HDmemcpy(&tempushort, vp, sizeof(unsigned short));
h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
} else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- memcpy(&templong, vp, sizeof(long));
+ HDmemcpy(&templong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
} else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- memcpy(&tempulong, vp, sizeof(unsigned long));
+ HDmemcpy(&tempulong, vp, sizeof(unsigned long));
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
} else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- memcpy(&templlong, vp, sizeof(long_long));
+ HDmemcpy(&templlong, vp, sizeof(long_long));
h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
} else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- memcpy(&tempullong, vp, sizeof(unsigned long_long));
+ HDmemcpy(&tempullong, vp, sizeof(unsigned long_long));
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
} else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
if (sizeof(hssize_t) == sizeof(int)) {
- memcpy(&tempint, vp, sizeof(int));
+ HDmemcpy(&tempint, vp, sizeof(int));
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
} else if (sizeof(hssize_t) == sizeof(long)) {
- memcpy(&templong, vp, sizeof(long));
+ HDmemcpy(&templong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
} else {
- memcpy(&templlong, vp, sizeof(long_long));
+ HDmemcpy(&templlong, vp, sizeof(long_long));
h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
}
} else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
if (sizeof(hsize_t) == sizeof(int)) {
- memcpy(&tempuint, vp, sizeof(unsigned int));
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
} else if (sizeof(hsize_t) == sizeof(long)) {
- memcpy(&tempulong, vp, sizeof(long));
+ HDmemcpy(&tempulong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
} else {
- memcpy(&tempullong, vp, sizeof(unsigned long_long));
+ HDmemcpy(&tempullong, vp, sizeof(unsigned long_long));
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
}
} else if (H5Tget_class(type) == H5T_COMPOUND) {
@@ -677,7 +677,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
/* The name */
name = H5Tget_member_name(type, j);
h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
- free(name);
+ HDfree(name);
/* The value */
offset = H5Tget_member_offset(type, j);
@@ -920,50 +920,50 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces)
for (i = 0; i < n; i++) {
switch (s[i]) {
- case '"':
- escape = "\\\"";
- break;
- case '\\':
- escape = "\\\\";
- break;
- case '\b':
- escape = "\\b";
- break;
- case '\f':
- escape = "\\f";
- break;
- case '\n':
- escape = "\\n";
- break;
- case '\r':
- escape = "\\r";
- break;
- case '\t':
- escape = "\\t";
- break;
- case ' ':
- escape = escape_spaces ? "\\ " : NULL;
- break;
- default:
- if (!isprint((int)*s)) {
- sprintf(octal, "\\%03o", (unsigned char)s[i]);
- escape = octal;
- } else {
- escape = NULL;
- }
-
- break;
+ case '"':
+ escape = "\\\"";
+ break;
+ case '\\':
+ escape = "\\\\";
+ break;
+ case '\b':
+ escape = "\\b";
+ break;
+ case '\f':
+ escape = "\\f";
+ break;
+ case '\n':
+ escape = "\\n";
+ break;
+ case '\r':
+ escape = "\\r";
+ break;
+ case '\t':
+ escape = "\\t";
+ break;
+ case ' ':
+ escape = escape_spaces ? "\\ " : NULL;
+ break;
+ default:
+ if (!isprint((int)*s)) {
+ sprintf(octal, "\\%03o", (unsigned char)s[i]);
+ escape = octal;
+ } else {
+ escape = NULL;
+ }
+
+ break;
}
if (escape) {
- size_t esc_size = strlen(escape);
+ size_t esc_size = HDstrlen(escape);
if (n + esc_size + 1 > size)
/*would overflow*/
return NULL;
- memmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/
- memcpy(s + i, escape, esc_size); /*insert*/
+ HDmemmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/
+ HDmemcpy(s + i, escape, esc_size); /*insert*/
n += esc_size;
i += esc_size - 1;
}
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 58b5ba9..b9aba72 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -24,7 +24,7 @@ extern char *h5tools_str_prefix(h5tools_str_t *str, const h5dump_t *info,
hsize_t elmtno, int ndims, hsize_t min_idx[],
hsize_t max_idx[]);
extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5dump_t *);
-extern void h5tools_print_char(h5tools_str_t *, const h5dump_t *, unsigned char);
+extern void h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch);
extern char *h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info,
hid_t container, hid_t type, void *vp,
h5tools_context_t *ctx);
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index a6050ca..9f5fa0a 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -52,13 +52,13 @@ error_msg(const char *progname, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- fflush(stdout);
+ HDfflush(stdout);
#ifdef WIN32
- fprintf(stdout, "%s error: ", progname);
- vfprintf(stdout, fmt, ap);
+ HDfprintf(stdout, "%s error: ", progname);
+ HDvfprintf(stdout, fmt, ap);
#else
- fprintf(stderr, "%s error: ", progname);
- vfprintf(stderr, fmt, ap);
+ HDfprintf(stderr, "%s error: ", progname);
+ HDvfprintf(stderr, fmt, ap);
#endif
va_end(ap);
@@ -86,9 +86,14 @@ warn_msg(const char *progname, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- fflush(stdout);
- fprintf(stderr, "%s warning: ", progname);
- vfprintf(stderr, fmt, ap);
+ HDfflush(stdout);
+#ifdef WIN32
+ HDfprintf(stdout, "%s warning: ", progname);
+ HDvfprintf(stdout, fmt, ap);
+#else /* WIN32 */
+ HDfprintf(stderr, "%s warning: ", progname);
+ HDvfprintf(stderr, fmt, ap);
+#endif /* WIN32 */
va_end(ap);
}
@@ -122,7 +127,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
/* check for more flag-like tokens */
if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
return EOF;
- } else if (strcmp(argv[opt_ind], "--") == 0) {
+ } else if (HDstrcmp(argv[opt_ind], "--") == 0) {
opt_ind++;
return EOF;
}
@@ -131,12 +136,12 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
/* long command line option */
const char *arg = &argv[opt_ind][2];
- register int i;
+ int i;
for (i = 0; l_opts && l_opts[i].name; i++) {
- size_t len = strlen(l_opts[i].name);
+ size_t len = HDstrlen(l_opts[i].name);
- if (strncmp(arg, l_opts[i].name, len) == 0) {
+ if (HDstrncmp(arg, l_opts[i].name, len) == 0) {
/* we've found a matching long command line flag */
opt_opt = l_opts[i].shortval;
@@ -147,7 +152,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_arg = argv[++opt_ind];
} else if (l_opts[i].has_arg == require_arg) {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: option required for \"--%s\" flag\n",
argv[0], arg);
@@ -156,7 +161,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
} else {
if (arg[len] == '=') {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: no option required for \"%s\" flag\n",
argv[0], arg);
@@ -173,7 +178,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (l_opts[i].name == NULL) {
/* exhausted all of the l_opts we have and still didn't match */
if (opt_err)
- fprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
+ HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
opt_opt = '?';
}
@@ -188,7 +193,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) {
if (opt_err)
- fprintf(stderr, "%s: unknown option \"%c\"\n",
+ HDfprintf(stderr, "%s: unknown option \"%c\"\n",
argv[0], opt_opt);
/* if no chars left in this token, move to next token */
@@ -207,7 +212,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_arg = &argv[opt_ind++][sp + 1];
} else if (++opt_ind >= argc) {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: value expected for option \"%c\"\n",
argv[0], opt_opt);
@@ -255,7 +260,7 @@ indentation(int x)
while (x-- > 0)
printf(" ");
} else {
- fprintf(stderr, "error: the indentation exceeds the number of cols.\n");
+ HDfprintf(stderr, "error: the indentation exceeds the number of cols.\n");
exit(1);
}
}
@@ -302,11 +307,11 @@ void
init_table(table_t **tbl)
{
int i;
- table_t *table = malloc(sizeof(table_t));
+ table_t *table = HDmalloc(sizeof(table_t));
table->size = 20;
table->nobjs = 0;
- table->objs = malloc(table->size * sizeof(obj_t));
+ table->objs = HDmalloc(table->size * sizeof(obj_t));
for (i = 0; i < table->size; i++) {
table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
@@ -334,7 +339,7 @@ void
init_prefix(char **prefix, int prefix_len)
{
assert(prefix_len > 0);
- *prefix = calloc((size_t)prefix_len, 1);
+ *prefix = HDcalloc((size_t)prefix_len, 1);
}
@@ -377,7 +382,7 @@ free_table(table_t **table)
int
search_obj(table_t *table, unsigned long *objno)
{
- register int i;
+ int i;
for (i = 0; i < table->nobjs; i++)
if (table->objs[i].objno[0] == *objno && table->objs[i].objno[1] == *(objno + 1))
@@ -409,7 +414,7 @@ find_objs(hid_t group, const char *name, void *op_data)
H5G_stat_t statbuf;
char *tmp;
find_objs_t *info = (find_objs_t*)op_data;
- register int i;
+ int i;
if (info->threshold > 1)
/*will get an infinite loop if greater than 1*/
@@ -417,93 +422,93 @@ find_objs(hid_t group, const char *name, void *op_data)
H5Gget_objinfo(group, name, TRUE, &statbuf);
- tmp = malloc(strlen(info->prefix) + strlen(name) + 2);
- strcpy(tmp, info->prefix);
+ tmp = HDmalloc(HDstrlen(info->prefix) + HDstrlen(name) + 2);
+ HDstrcpy(tmp, info->prefix);
switch (statbuf.type) {
- case H5G_GROUP:
- if ((obj = H5Gopen(group, name)) >= 0) {
- if (info->prefix_len < (int)(strlen(info->prefix) + strlen(name) + 2)) {
- info->prefix_len *= 2;
- info->prefix = realloc(info->prefix,
- info->prefix_len * sizeof(char));
- }
+ case H5G_GROUP:
+ if ((obj = H5Gopen(group, name)) >= 0) {
+ if (info->prefix_len < (int)(HDstrlen(info->prefix) + HDstrlen(name) + 2)) {
+ info->prefix_len *= 2;
+ info->prefix = HDrealloc(info->prefix,
+ info->prefix_len * sizeof(char));
+ }
- strcat(strcat(info->prefix,"/"), name);
+ HDstrcat(HDstrcat(info->prefix,"/"), name);
- if (statbuf.nlink > info->threshold) {
- if (search_obj(info->group_table, statbuf.objno) == FAIL) {
- add_obj(info->group_table, statbuf.objno, info->prefix);
- H5Giterate(obj, ".", NULL, find_objs, (void *)info);
+ if (statbuf.nlink > info->threshold) {
+ if (search_obj(info->group_table, statbuf.objno) == FAIL) {
+ add_obj(info->group_table, statbuf.objno, info->prefix);
+ H5Giterate(obj, ".", NULL, find_objs, (void *)info);
+ }
+ } else {
+ H5Giterate (obj, ".", NULL, find_objs, (void *)info);
}
- } else {
- H5Giterate (obj, ".", NULL, find_objs, (void *)info);
- }
- strcpy(info->prefix, tmp);
- H5Gclose (obj);
- } else {
- info->status = 1;
- }
+ HDstrcpy(info->prefix, tmp);
+ H5Gclose (obj);
+ } else {
+ info->status = 1;
+ }
- break;
+ break;
- case H5G_DATASET:
- strcat(tmp,"/");
- strcat(tmp,name); /* absolute name of the data set */
+ case H5G_DATASET:
+ HDstrcat(tmp,"/");
+ HDstrcat(tmp,name); /* absolute name of the data set */
- if (statbuf.nlink > info->threshold &&
- search_obj(info->dset_table, statbuf.objno) == FAIL)
- add_obj(info->dset_table, statbuf.objno, tmp);
+ if (statbuf.nlink > info->threshold &&
+ search_obj(info->dset_table, statbuf.objno) == FAIL)
+ add_obj(info->dset_table, statbuf.objno, tmp);
- if ((obj = H5Dopen (group, name)) >= 0) {
- type = H5Dget_type(obj);
+ if ((obj = H5Dopen (group, name)) >= 0) {
+ type = H5Dget_type(obj);
- if (H5Tcommitted(type) > 0) {
- H5Gget_objinfo(type, ".", TRUE, &statbuf);
+ if (H5Tcommitted(type) > 0) {
+ H5Gget_objinfo(type, ".", TRUE, &statbuf);
- if (search_obj(info->type_table, statbuf.objno) == FAIL) {
- add_obj(info->type_table, statbuf.objno, tmp);
- info->type_table->objs[info->type_table->nobjs - 1].objflag = 0;
+ if (search_obj(info->type_table, statbuf.objno) == FAIL) {
+ add_obj(info->type_table, statbuf.objno, tmp);
+ info->type_table->objs[info->type_table->nobjs - 1].objflag = 0;
+ }
}
- }
- H5Tclose(type);
- H5Dclose (obj);
- } else {
- info->status = 1;
- }
-
- break;
+ H5Tclose(type);
+ H5Dclose (obj);
+ } else {
+ info->status = 1;
+ }
+
+ break;
- case H5G_TYPE:
- strcat(tmp,"/");
- strcat(tmp,name); /* absolute name of the type */
- i = search_obj(info->type_table, statbuf.objno);
+ case H5G_TYPE:
+ HDstrcat(tmp,"/");
+ HDstrcat(tmp,name); /* absolute name of the type */
+ i = search_obj(info->type_table, statbuf.objno);
- if (i == FAIL) {
- add_obj(info->type_table, statbuf.objno, tmp) ;
+ if (i == FAIL) {
+ add_obj(info->type_table, statbuf.objno, tmp) ;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].recorded = 1;
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].recorded = 1;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
- } else {
- strcpy (info->type_table->objs[i].objname, tmp);
- info->type_table->objs[i].recorded = 1;
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
+ } else {
+ strcpy (info->type_table->objs[i].objname, tmp);
+ info->type_table->objs[i].recorded = 1;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
- }
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
+ }
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
- free(tmp);
+ HDfree(tmp);
return SUCCEED;
}
@@ -524,7 +529,7 @@ find_objs(hid_t group, const char *name, void *op_data)
void
dump_table(char* tablename, table_t *table)
{
- register int i;
+ int i;
printf("%s: # of entries = %d\n", tablename,table->nobjs);
@@ -612,7 +617,7 @@ set_tableflag(table_t *table, int idx)
char *
get_objectname(table_t *table, int idx)
{
- return strdup(table->objs[idx].objname);
+ return HDstrdup(table->objs[idx].objname);
}
@@ -633,11 +638,11 @@ get_objectname(table_t *table, int idx)
static void
add_obj(table_t *table, unsigned long *objno, char *objname)
{
- register int i;
+ int i;
if (table->nobjs == table->size) {
table->size *= 2;
- table->objs = realloc(table->objs, table->size * sizeof(obj_t));
+ table->objs = HDrealloc(table->objs, table->size * sizeof(obj_t));
for (i = table->nobjs; i < table->size; i++) {
table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
@@ -650,5 +655,5 @@ add_obj(table_t *table, unsigned long *objno, char *objname)
i = table->nobjs++;
table->objs[i].objno[0] = objno[0];
table->objs[i].objno[1] = objno[1];
- strcpy(table->objs[i].objname, objname);
+ HDstrcpy(table->objs[i].objname, objname);
}