summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2013-07-08 15:52:49 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2013-07-08 15:52:49 (GMT)
commit528e0d1cac689310beecf02e56a10b764afa2651 (patch)
tree55b458aedb657440c0cd124f9d6d9f521153db6f /hl
parent38bdc241ed4f62c9d628de563f6f98f3dda6281c (diff)
downloadhdf5-528e0d1cac689310beecf02e56a10b764afa2651.zip
hdf5-528e0d1cac689310beecf02e56a10b764afa2651.tar.gz
hdf5-528e0d1cac689310beecf02e56a10b764afa2651.tar.bz2
[svn-r23869] HDFFV-8302: replace (v)snprintf with _(v)snprintf for windows. Merge from trunk along with other windows functions and HD prefix corrections.
HDFFV-8394: Add cmake code to package examples Tested: local linux
Diffstat (limited to 'hl')
-rw-r--r--hl/c++/test/ptableTest.cpp17
-rw-r--r--hl/examples/ex_image2.c8
-rw-r--r--hl/src/H5IM.c4
-rw-r--r--hl/src/H5LT.c87
-rw-r--r--hl/src/H5LTanalyze.c32
-rw-r--r--hl/src/H5LTanalyze.l4
-rw-r--r--hl/src/H5LTparse.y4
-rw-r--r--hl/test/test_image.c9
8 files changed, 112 insertions, 53 deletions
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index a2b5efd..929058d 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -183,9 +183,17 @@ int TestCompoundDatatype()
goto out;
PASSED();
+
+ H5Tclose(dtypeID);
return 0;
out:
+
+ H5E_BEGIN_TRY {
+ H5Tclose(dtypeID);
+ } H5E_END_TRY;
+
+
H5_FAILED();
return 1;
}
@@ -515,10 +523,19 @@ int SystemTest()
if(ct1[1].b != ct2[2].g.b)
goto out;
+ H5Tclose(dtypeID1);
+ H5Tclose(dtypeID2);
+
PASSED();
return 0;
out:
+
+ H5E_BEGIN_TRY {
+ H5Tclose(dtypeID1);
+ H5Tclose(dtypeID2);
+ } H5E_END_TRY;
+
H5_FAILED();
return 1;
}
diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c
index 77398c4..76c3a75 100644
--- a/hl/examples/ex_image2.c
+++ b/hl/examples/ex_image2.c
@@ -46,6 +46,10 @@ int main( void )
/* make the image */
status=H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf );
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
/*-------------------------------------------------------------------------
* define a palette, blue to red tones
@@ -75,6 +79,10 @@ int main( void )
/* make dataset */
status=H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf );
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
/* close the file. */
H5Fclose( file_id );
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c
index 11f4014..2621ca4 100644
--- a/hl/src/H5IM.c
+++ b/hl/src/H5IM.c
@@ -564,7 +564,7 @@ herr_t H5IMlink_palette( hid_t loc_id,
/* close */
if(H5Sclose(asid) < 0)
goto out;
- if ( H5Tclose( atid ) < 0)
+ if(H5Tclose(atid) < 0)
goto out;
if(H5Aclose(aid) < 0)
goto out;
@@ -630,6 +630,8 @@ herr_t H5IMlink_palette( hid_t loc_id,
/* close */
if(H5Sclose(asid) < 0)
goto out;
+ if(H5Tclose(atid) < 0)
+ goto out;
if(H5Aclose(aid) < 0)
goto out;
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 678642f..b2c8949 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -803,7 +803,7 @@ herr_t H5LTmake_dataset_string(hid_t loc_id,
if((tid = H5Tcopy(H5T_C_S1)) < 0 )
goto out;
- size = strlen(buf) + 1; /* extra null term */
+ size = HDstrlen(buf) + 1; /* extra null term */
if(H5Tset_size(tid, size) < 0)
goto out;
@@ -1354,7 +1354,7 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d
* cause the iterator to immediately return that positive value,
* indicating short-circuit success
*/
- if(strcmp(name, (char *)op_data) == 0)
+ if(HDstrcmp(name, (char *)op_data) == 0)
ret = 1;
return ret;
@@ -1437,7 +1437,7 @@ herr_t H5LTset_attribute_string( hid_t loc_id,
if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 )
goto out;
- attr_size = strlen( attr_data ) + 1; /* extra null term */
+ attr_size = HDstrlen( attr_data ) + 1; /* extra null term */
if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 )
goto out;
@@ -1936,7 +1936,7 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
* cause the iterator to immediately return that positive value,
* indicating short-circuit success
*/
- if(strcmp(name, (char *)op_data) == 0)
+ if(HDstrcmp(name, (char *)op_data) == 0)
ret = H5_ITER_STOP;
return ret;
@@ -2168,17 +2168,19 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type)
goto out;
if(lang_type != H5LT_DDL) {
- fprintf(stderr, "only DDL is supported for now.\n");
+ HDfprintf(stderr, "only DDL is supported for now.\n");
goto out;
}
- input_len = strlen(text);
- myinput = strdup(text);
+ input_len = HDstrlen(text);
+ myinput = HDstrdup(text);
- if((type_id = H5LTyyparse()) < 0)
+ if((type_id = H5LTyyparse()) < 0) {
+ HDfree(myinput);
goto out;
+ }
- free(myinput);
+ HDfree(myinput);
input_len = 0;
return type_id;
@@ -2207,12 +2209,12 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad
{
if(_no_user_buf) {
/* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */
- if(str_to_add && ((ssize_t)(*len - (strlen(buf) + strlen(str_to_add) + 1)) < LIMIT)) {
- *len += ((strlen(buf) + strlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT;
- buf = (char*)realloc(buf, *len);
- } else if(!str_to_add && ((ssize_t)(*len - strlen(buf) - 1) < LIMIT)) {
+ if(str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) {
+ *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT;
+ buf = (char*)HDrealloc(buf, *len);
+ } else if(!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) {
*len += INCREMENT;
- buf = (char*)realloc(buf, *len);
+ buf = (char*)HDrealloc(buf, *len);
}
}
@@ -2220,7 +2222,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad
goto out;
if(str_to_add)
- strcat(buf, str_to_add);
+ HDstrcat(buf, str_to_add);
return buf;
@@ -2249,7 +2251,7 @@ indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len)
char tmp_str[TMP_LEN];
if (x < 80) {
- memset(tmp_str, ' ', x);
+ HDmemset(tmp_str, ' ', x);
tmp_str[x]='\0';
} else
HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols.");
@@ -2310,8 +2312,8 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
dst_size = H5Tget_size(native);
/* Get the names and raw values of all members */
- name = (char**)calloc((size_t)nmembs, sizeof(char *));
- value = (unsigned char*)calloc((size_t)nmembs, MAX(dst_size, super_size));
+ name = (char**)HDcalloc((size_t)nmembs, sizeof(char *));
+ value = (unsigned char*)HDcalloc((size_t)nmembs, MAX(dst_size, super_size));
for (i = 0; i < nmembs; i++) {
if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL)
@@ -2359,10 +2361,10 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
/* Release resources */
for(i = 0; i < nmembs; i++)
- free(name[i]);
+ HDfree(name[i]);
- free(name);
- free(value);
+ HDfree(name);
+ HDfree(value);
H5Tclose(super);
return str;
@@ -2378,12 +2380,12 @@ out:
if(name) {
for(i = 0; i < nmembs; i++)
if(name[i])
- free(name[i]);
- free(name);
+ HDfree(name[i]);
+ HDfree(name);
} /* end if */
if(value)
- free(value);
+ HDfree(value);
if(super >= 0)
H5Tclose(super);
@@ -2418,13 +2420,13 @@ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *
goto out;
if(len && !str) {
- text_str = (char*)calloc(str_len, sizeof(char));
+ text_str = (char*)HDcalloc(str_len, sizeof(char));
text_str[0]='\0';
if(!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1)))
goto out;
- *len = strlen(text_str) + 1;
+ *len = HDstrlen(text_str) + 1;
if(text_str)
- free(text_str);
+ HDfree(text_str);
text_str = NULL;
} else if(len && str) {
if(!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0)))
@@ -2744,7 +2746,7 @@ next:
if(tag) {
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag);
if(tag)
- free(tag);
+ HDfree(tag);
tag = NULL;
} else
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n");
@@ -2777,14 +2779,14 @@ next:
goto out;
if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
+ stmp = (char*)HDcalloc(super_len, sizeof(char));
if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
goto out;
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
goto out;
if(stmp)
- free(stmp);
+ HDfree(stmp);
stmp = NULL;
HDsnprintf(tmp_str, TMP_LEN, ";\n");
@@ -2821,14 +2823,14 @@ next:
goto out;
if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
+ stmp = (char*)HDcalloc(super_len, sizeof(char));
if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
goto out;
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
goto out;
if(stmp)
- free(stmp);
+ HDfree(stmp);
stmp = NULL;
HDsnprintf(tmp_str, TMP_LEN, "\n");
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
@@ -2879,13 +2881,13 @@ next:
goto out;
if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
+ stmp = (char*)HDcalloc(super_len, sizeof(char));
if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
goto out;
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
goto out;
if(stmp)
- free(stmp);
+ HDfree(stmp);
stmp = NULL;
HDsnprintf(tmp_str, TMP_LEN, "\n");
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
@@ -2934,13 +2936,13 @@ next:
if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0)
goto out;
- mtmp = (char*)calloc(mlen, sizeof(char));
+ mtmp = (char*)HDcalloc(mlen, sizeof(char));
if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0)
goto out;
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp)))
goto out;
if(mtmp)
- free(mtmp);
+ HDfree(mtmp);
mtmp = NULL;
if (H5T_COMPOUND == mclass)
@@ -2950,7 +2952,7 @@ next:
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
if(mname)
- free(mname);
+ HDfree(mname);
mname = NULL;
HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset);
@@ -3024,8 +3026,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id,
return -1;
/* Get the attribute */
- if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 )
- return -1;
+ if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 )
+ {
+ H5Oclose(obj_id);
+ return -1;
+ }
/* Close the object */
if(H5Oclose(obj_id) < 0)
@@ -3458,6 +3463,8 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id,
return 0;
out:
+ if(obj_id > 0)
+ H5Oclose(obj_id);
if(attr_id > 0)
H5Aclose(attr_id);
return -1;
@@ -3555,7 +3562,7 @@ herr_t H5LT_set_attribute_string(hid_t dset_id,
if((tid = H5Tcopy(H5T_C_S1)) < 0)
return FAIL;
- size = strlen(buf) + 1; /* extra null term */
+ size = HDstrlen(buf) + 1; /* extra null term */
if(H5Tset_size(tid,(size_t)size) < 0)
goto out;
diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c
index b88b577..f02bed6 100644
--- a/hl/src/H5LTanalyze.c
+++ b/hl/src/H5LTanalyze.c
@@ -51,7 +51,7 @@
#include <stdio.h>
#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
-#endif
+#endif
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
@@ -1400,54 +1400,58 @@ case 57:
YY_RULE_SETUP
#line 159 "H5LTanalyze.l"
{
+#ifdef H5_HAVE_WIN32_API
+ H5LTyylval.sval = _strdup(yytext);
+#else /* H5_HAVE_WIN32_API */
H5LTyylval.sval = strdup(yytext);
+#endif /* H5_HAVE_WIN32_API */
BEGIN INITIAL;
return STRING;
}
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 165 "H5LTanalyze.l"
+#line 169 "H5LTanalyze.l"
{return token('{');}
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 166 "H5LTanalyze.l"
+#line 170 "H5LTanalyze.l"
{return token('}');}
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 167 "H5LTanalyze.l"
+#line 171 "H5LTanalyze.l"
{return token('[');}
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 168 "H5LTanalyze.l"
+#line 172 "H5LTanalyze.l"
{return token(']');}
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 169 "H5LTanalyze.l"
+#line 173 "H5LTanalyze.l"
{return token(':');}
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 170 "H5LTanalyze.l"
+#line 174 "H5LTanalyze.l"
{return token(';');}
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 171 "H5LTanalyze.l"
+#line 175 "H5LTanalyze.l"
;
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 172 "H5LTanalyze.l"
+#line 176 "H5LTanalyze.l"
{ return 0; }
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 174 "H5LTanalyze.l"
+#line 178 "H5LTanalyze.l"
ECHO;
YY_BREAK
#line 1432 "H5LTanalyze.c"
@@ -2032,7 +2036,11 @@ FILE *file;
#if YY_NEVER_INTERACTIVE
b->yy_is_interactive = 0;
#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#ifdef H5_HAVE_WIN32_API
+ b->yy_is_interactive = file ? (isatty( _fileno(file) ) > 0) : 0;
+#else /* H5_HAVE_WIN32_API */
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif /* H5_HAVE_WIN32_API */
#endif
#endif
}
@@ -2327,7 +2335,7 @@ int main()
return 0;
}
#endif
-#line 174 "H5LTanalyze.l"
+#line 178 "H5LTanalyze.l"
int my_yyinput(char *buf, int max_size)
{
diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l
index 3f63f50..581672b 100644
--- a/hl/src/H5LTanalyze.l
+++ b/hl/src/H5LTanalyze.l
@@ -157,7 +157,11 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);}
return token('"');
}
<TAG_STRING>[^\"]+ {
+#ifdef H5_HAVE_WIN32_API
+ H5LTyylval.sval = _strdup(yytext);
+#else /* H5_HAVE_WIN32_API */
H5LTyylval.sval = strdup(yytext);
+#endif /* H5_HAVE_WIN32_API */
BEGIN INITIAL;
return STRING;
}
diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y
index a021efc..b91e97e 100644
--- a/hl/src/H5LTparse.y
+++ b/hl/src/H5LTparse.y
@@ -329,7 +329,11 @@ enum_list :
;
enum_def : '"' enum_symbol '"' {
is_enum_memb = 1; /*indicate member of enum*/
+#ifdef H5_HAVE_WIN32_API
+ enum_memb_symbol = _strdup(yylval.sval);
+#else /* H5_HAVE_WIN32_API */
enum_memb_symbol = strdup(yylval.sval);
+#endif /* H5_HAVE_WIN32_API */
}
enum_val ';'
{
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 5c0c7ca..5a52980 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -289,6 +289,15 @@ static int test_simple(void)
*-------------------------------------------------------------------------
*/
+ if(buf1)
+ HDfree(buf1);
+ if(buf2)
+ HDfree(buf2);
+ if(buf1_out)
+ HDfree(buf1_out);
+ if(buf2_out)
+ HDfree(buf2_out);
+
/* Close the file. */
if(H5Fclose( fid ) < 0)
goto out;