diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-22 00:21:18 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-22 00:21:18 (GMT) |
commit | d3c6b4ad7244f46c863d47f630e1c9b0427abed5 (patch) | |
tree | bf76f37066c26a76422483f3088f4dbcb6ced5be /tools/lib/h5tools_str.c | |
parent | fd90a6f5c4c7733027c711e70e2df1b18e8e5286 (diff) | |
download | hdf5-d3c6b4ad7244f46c863d47f630e1c9b0427abed5.zip hdf5-d3c6b4ad7244f46c863d47f630e1c9b0427abed5.tar.gz hdf5-d3c6b4ad7244f46c863d47f630e1c9b0427abed5.tar.bz2 |
[svn-r27848] Description:
Clean up warnings and some normalization against trunk.
Tested:
McaOSX/64 10.10.5 (amazon) w/serial & parallel
(h5committest not required on this branch)
Diffstat (limited to 'tools/lib/h5tools_str.c')
-rw-r--r-- | tools/lib/h5tools_str.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index c10f33b..bdb82a4 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1456,23 +1456,22 @@ h5tools_str_is_zero(const void *_mem, size_t size) char * h5tools_str_replace ( const char *string, const char *substr, const char *replacement ) { - char *tok = NULL; - char *newstr = NULL; - char *oldstr = NULL; - char *head = NULL; - - if ( substr == NULL || replacement == NULL ) - return HDstrdup (string); - - newstr = HDstrdup (string); - head = newstr; - while ( (tok = HDstrstr ( head, substr ))){ - oldstr = newstr; - newstr = (char *)HDmalloc( HDstrlen( oldstr ) - HDstrlen( substr ) + HDstrlen( replacement ) + 1 ); + char *tok = NULL; + char *newstr = NULL; + char *oldstr = NULL; + char *head = NULL; + + if ( substr == NULL || replacement == NULL ) + return HDstrdup (string); + newstr = HDstrdup (string); + head = newstr; + while ( (tok = HDstrstr ( head, substr ))){ + oldstr = newstr; + newstr = (char *)HDmalloc( HDstrlen( oldstr ) - HDstrlen( substr ) + HDstrlen( replacement ) + 1 ); if ( newstr == NULL ){ - HDfree (oldstr); - return NULL; + HDfree (oldstr); + return NULL; } HDmemcpy ( newstr, oldstr, tok - oldstr ); HDmemcpy ( newstr + (tok - oldstr), replacement, HDstrlen ( replacement ) ); |