summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-02 21:37:24 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-02 21:37:24 (GMT)
commit1ed3d8d77ec680b8ced982b1afdac94fd00c8a84 (patch)
treecb190fb2bb62da0c6fb06566636688c3163b144d /examples
parenta993ec82fd294da1123a6d5934b98eb77d69e921 (diff)
downloadhdf5-1ed3d8d77ec680b8ced982b1afdac94fd00c8a84.zip
hdf5-1ed3d8d77ec680b8ced982b1afdac94fd00c8a84.tar.gz
hdf5-1ed3d8d77ec680b8ced982b1afdac94fd00c8a84.tar.bz2
[svn-r12848] Description:
Change H5Pset_elink_prefix to be more similar to rest of library and make a copy of the string passed in. Change H5Pget_elink_prefix to be link rest of library routines that query a string. Tested on: FreeBSD/32 4.11 (sleipnir) w/threadsafe & debugging turned on Linux/32 2.4 (heping) w/FORTRAN & C++ Linux/64 2.4 (mir) w/build-all & 1.6 compat enabled AIX/32 5.x (copper) w/FORTRAN & parallel
Diffstat (limited to 'examples')
-rw-r--r--examples/h5_elink_unix2win.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/h5_elink_unix2win.c b/examples/h5_elink_unix2win.c
index b4998fd..447d392 100644
--- a/examples/h5_elink_unix2win.c
+++ b/examples/h5_elink_unix2win.c
@@ -45,6 +45,7 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group, void *
char *obj_name;
char *elink_prefix; /* External link prefix */
char *new_fname = NULL; /* Buffer allocated to hold Unix file path */
+ ssize_t prefix_len; /* External link prefix length */
size_t fname_len;
size_t start_pos; /* Initial position in new_fname buffer */
size_t x; /* Counter variable */
@@ -57,25 +58,22 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group, void *
fname_len = strlen(file_name);
/* See if the external link prefix property is set */
- if(H5Pget_elink_prefix(lapl_id, &elink_prefix) < 0)
+ if((prefix_len = H5Pget_elink_prefix(lapl_id, NULL, 0)) < 0)
goto error;
/* If so, prepend it to the filename. We assume that the prefix
* is in the correct format for the current file system.
*/
- if(elink_prefix != NULL)
+ if(prefix_len > 0)
{
- size_t buf_size; /* Size prefix buffer */
-
- buf_size = strlen(elink_prefix);
-
/* Allocate a buffer to hold the filename plus prefix */
- new_fname = malloc(buf_size + fname_len + 1);
+ new_fname = malloc(prefix_len + fname_len + 1);
/* Copy the prefix into the buffer */
- strcpy(new_fname, elink_prefix);
+ if(H5Pget_elink_prefix(lapl_id, new_fname, prefix_len + 1) < 0)
+ goto error;
- start_pos = buf_size;
+ start_pos = prefix_len;
}
else
{