mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r5929]
Purpose: bug fix Description: memory leak regarding the ID to name buffer Solution: added a new function H5G_free_ent_name that is called on several places of the library Platforms tested: windows 2000 linux, with cpp solaris, with fortran, cpp irix64, with parallel, fortran
This commit is contained in:
parent
d32ad09043
commit
2aca3b77d6
@ -1904,6 +1904,9 @@ done:
|
||||
*
|
||||
* Quincey Koziol, 12 Oct 1998
|
||||
* Moved guts of function into H5D_open_oid
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1932,6 +1935,10 @@ H5D_open(H5G_entry_t *loc, const char *name)
|
||||
ret_value = dataset;
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&ent);
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
|
@ -1456,6 +1456,10 @@ done:
|
||||
* Robb Matzke, 2000-10-31
|
||||
* H5FL_FREE() aborts if called with a null pointer (unlike the
|
||||
* original H5MM_free()).
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
@ -1472,6 +1476,10 @@ H5F_dest(H5F_t *f)
|
||||
* the memory associated with it.
|
||||
*/
|
||||
if (f->shared->root_grp) {
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_grp_name(f->shared->root_grp);
|
||||
|
||||
H5FL_FREE(H5G_t,f->shared->root_grp);
|
||||
f->shared->root_grp=NULL;
|
||||
}
|
||||
|
297
src/H5G.c
297
src/H5G.c
@ -1057,16 +1057,19 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
|
||||
H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/,
|
||||
unsigned target, int *nlinks)
|
||||
{
|
||||
H5G_entry_t _grp_ent; /*entry for current group */
|
||||
H5G_entry_t _obj_ent; /*entry found */
|
||||
size_t nchars; /*component name length */
|
||||
int _nlinks = H5G_NLINKS;
|
||||
const char *s = NULL;
|
||||
herr_t ret_value=SUCCEED; /* Return value */
|
||||
H5G_entry_t _grp_ent; /*entry for current group */
|
||||
H5G_entry_t _obj_ent; /*entry found */
|
||||
size_t nchars; /*component name length */
|
||||
int _nlinks = H5G_NLINKS;
|
||||
const char *s = NULL;
|
||||
herr_t ret_value=SUCCEED;
|
||||
|
||||
|
||||
H5G_t *tmp_grp;
|
||||
const char *orig_name = name;
|
||||
H5G_entry_t tmp_obj_ent; /*temporary entry for search */
|
||||
H5G_t *tmp_grp;
|
||||
const char *orig_name = name;
|
||||
unsigned int null_obj = obj_ent == NULL ? 1 : 0;
|
||||
unsigned int null_grp = grp_ent == NULL ? 1 : 0;
|
||||
unsigned int found_once = 0;
|
||||
|
||||
FUNC_ENTER_NOINIT(H5G_namei);
|
||||
|
||||
@ -1080,27 +1083,31 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
|
||||
* root of the file; for relative names it starts at CWG.
|
||||
*/
|
||||
if (!name || !*name) {
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given");
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given");
|
||||
} else if (!loc_ent) {
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
|
||||
} else if ('/' == *name) {
|
||||
tmp_grp=H5G_rootof(loc_ent->file);
|
||||
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy( &(tmp_grp->ent), obj_ent )<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
|
||||
|
||||
|
||||
tmp_grp=H5G_rootof(loc_ent->file);
|
||||
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy( &(tmp_grp->ent), obj_ent )<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
|
||||
|
||||
|
||||
} else {
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy( loc_ent, obj_ent )<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy( loc_ent, obj_ent )<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HDmemset(grp_ent, 0, sizeof(H5G_entry_t));
|
||||
grp_ent->header = HADDR_UNDEF;
|
||||
|
||||
/* traverse the name */
|
||||
while ((name = H5G_component(name, &nchars)) && *name) {
|
||||
while ((name = H5G_component(name, &nchars)) && *name) {
|
||||
if (rest) *rest = name;
|
||||
|
||||
/*
|
||||
@ -1129,36 +1136,25 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
|
||||
/*
|
||||
* Advance to the next component of the name.
|
||||
*/
|
||||
if(found_once) {
|
||||
if(grp_ent->name)
|
||||
H5MM_xfree(grp_ent->name);
|
||||
if(grp_ent->old_name)
|
||||
H5MM_xfree(grp_ent->old_name);
|
||||
}
|
||||
*grp_ent = *obj_ent;
|
||||
HDmemset(obj_ent, 0, sizeof(H5G_entry_t));
|
||||
obj_ent->header = HADDR_UNDEF;
|
||||
/* Set flag if at least one component was found */
|
||||
found_once =1;
|
||||
|
||||
/* Temporary entry */
|
||||
tmp_obj_ent = *obj_ent;
|
||||
|
||||
if (H5G_stab_find(grp_ent, H5G_comp_g, &tmp_obj_ent/*out*/)<0) {
|
||||
if (H5G_stab_find(grp_ent, H5G_comp_g, /*&tmp_obj_ent*/ obj_ent/*out*/ )<0) {
|
||||
/*
|
||||
* Component was not found in the current symbol table, possibly
|
||||
* because GRP_ENT isn't a symbol table.
|
||||
*/
|
||||
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
|
||||
}
|
||||
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy( &tmp_obj_ent, obj_ent )<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
|
||||
|
||||
/* Remove the 'ID to name' info, if the entry is mot the one we want */
|
||||
if ( tmp_obj_ent.name ) {
|
||||
if (HDstrcmp(orig_name,tmp_obj_ent.name)!=0)
|
||||
{
|
||||
/* Free the ID to name buffers */
|
||||
if ( tmp_obj_ent.name )
|
||||
tmp_obj_ent.name = H5MM_xfree(tmp_obj_ent.name);
|
||||
if ( tmp_obj_ent.old_name )
|
||||
tmp_obj_ent.old_name = H5MM_xfree(tmp_obj_ent.old_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -1195,7 +1191,19 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
|
||||
*rest = name; /*final null */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
if(null_obj) {
|
||||
if(obj_ent->name)
|
||||
H5MM_xfree(obj_ent->name);
|
||||
if(obj_ent->old_name)
|
||||
H5MM_xfree(obj_ent->old_name);
|
||||
}
|
||||
if(null_grp && found_once) {
|
||||
if(grp_ent->name)
|
||||
H5MM_xfree(grp_ent->name);
|
||||
if(grp_ent->old_name)
|
||||
H5MM_xfree(grp_ent->old_name);
|
||||
}
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
|
||||
@ -1229,11 +1237,12 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
|
||||
{
|
||||
H5O_stab_t stab_mesg; /*info about local heap */
|
||||
const char *clv = NULL; /*cached link value */
|
||||
char *linkval = NULL; /*the copied link value */
|
||||
char *linkval = NULL; /*the copied link value */
|
||||
herr_t ret_value=SUCCEED; /* Return value */
|
||||
H5G_entry_t tmp;
|
||||
|
||||
/*Store old name */
|
||||
char* old_name=obj_ent->name;
|
||||
char* old_name = H5MM_strdup(obj_ent->name);
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_traverse_slink, FAIL);
|
||||
|
||||
@ -1245,13 +1254,28 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbolic link value");
|
||||
linkval = H5MM_xstrdup (clv);
|
||||
|
||||
|
||||
/* Free the ID to name buffer */
|
||||
H5G_free_ent_name(obj_ent);
|
||||
H5G_free_ent_name(grp_ent);
|
||||
|
||||
H5G_ent_copy(grp_ent,&tmp);
|
||||
|
||||
/* Traverse the link */
|
||||
if (H5G_namei (grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks))
|
||||
if (H5G_namei (&tmp, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks))
|
||||
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link");
|
||||
|
||||
|
||||
/* Free the ID to name buffer */
|
||||
H5G_free_ent_name(obj_ent);
|
||||
|
||||
obj_ent->name = old_name;
|
||||
|
||||
|
||||
done:
|
||||
|
||||
if ( ret_value == FAIL )
|
||||
H5MM_xfree (old_name);
|
||||
H5G_free_ent_name(&tmp);
|
||||
H5MM_xfree (linkval);
|
||||
FUNC_LEAVE (ret_value);
|
||||
}
|
||||
@ -1358,6 +1382,9 @@ done:
|
||||
* Aug 11 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1377,6 +1404,8 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
|
||||
assert(loc);
|
||||
assert(name && *name);
|
||||
|
||||
HDmemset(&grp_ent, 0, sizeof(H5G_entry_t));
|
||||
|
||||
/* lookup name */
|
||||
if (0 == H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL))
|
||||
HGOTO_ERROR(H5E_SYM, H5E_EXISTS, NULL, "already exists");
|
||||
@ -1419,8 +1448,12 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
|
||||
ret_value=grp;
|
||||
|
||||
done:
|
||||
if(ret_value==NULL) {
|
||||
if(grp!=NULL)
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
|
||||
if(ret_value==NULL) {
|
||||
if(grp!=NULL)
|
||||
H5FL_FREE(H5G_t,grp);
|
||||
} /* end if */
|
||||
|
||||
@ -1480,6 +1513,9 @@ done:
|
||||
* Modifications:
|
||||
* Modified to call H5G_open_oid - QAK - 3/17/99
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5G_t *
|
||||
@ -1510,6 +1546,10 @@ done:
|
||||
if (!ret_value && grp)
|
||||
H5FL_FREE(H5G_t,grp);
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&ent);
|
||||
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -1701,6 +1741,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -1755,6 +1798,9 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent)
|
||||
}
|
||||
|
||||
done:
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp);
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -1961,6 +2007,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -2042,6 +2091,9 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
|
||||
*/
|
||||
if (H5G_stab_insert (&grp_ent, rest, &cur_obj)<0)
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object");
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case H5G_LINK_HARD:
|
||||
@ -2049,6 +2101,8 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
|
||||
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found");
|
||||
if (H5G_insert (new_loc, new_name, &cur_obj)<0)
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object");
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2056,6 +2110,12 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if ( type == H5G_LINK_SOFT )
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
|
||||
H5G_free_ent_name(&cur_obj);
|
||||
FUNC_LEAVE (ret_value);
|
||||
}
|
||||
|
||||
@ -2117,6 +2177,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -2182,6 +2245,11 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
H5G_free_ent_name(&obj_ent);
|
||||
|
||||
FUNC_LEAVE (ret_value);
|
||||
}
|
||||
|
||||
@ -2204,6 +2272,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -2241,6 +2312,10 @@ H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/)
|
||||
HDstrncpy (buf, s, size);
|
||||
|
||||
done:
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
H5G_free_ent_name(&obj_ent);
|
||||
|
||||
FUNC_LEAVE (ret_value);
|
||||
}
|
||||
|
||||
@ -2257,6 +2332,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -2285,6 +2363,10 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf)
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&obj_ent);
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -2305,6 +2387,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
@ -2334,6 +2419,10 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf)
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&obj_ent);
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -2350,6 +2439,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
@ -2378,6 +2470,11 @@ H5G_unlink(H5G_entry_t *loc, const char *name)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink name from symbol table");
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
H5G_free_ent_name(&obj_ent);
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -2478,6 +2575,9 @@ done:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5F_t *
|
||||
@ -2511,11 +2611,91 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name)
|
||||
ret_value=grp_ent.file;
|
||||
|
||||
done:
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(&grp_ent);
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5G_free_grp_name
|
||||
*
|
||||
* Purpose: Free the 'ID to name' buffers.
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: August 22, 2002
|
||||
*
|
||||
* Comments: Used now only on the root group close , on H5F_close
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5G_free_grp_name(H5G_t *grp)
|
||||
{
|
||||
herr_t ret_value=SUCCEED; /* Return value */
|
||||
H5G_entry_t *ent;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL);
|
||||
|
||||
/* Check args */
|
||||
assert(grp);
|
||||
assert(grp->nref > 0);
|
||||
|
||||
if (NULL==( ent = H5G_entof(grp)))
|
||||
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "cannot get entry");
|
||||
|
||||
H5G_free_ent_name(ent);
|
||||
|
||||
|
||||
done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5G_free_ent_name
|
||||
*
|
||||
* Purpose: Free the 'ID to name' buffers.
|
||||
*
|
||||
* Return: Success
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: August 22, 2002
|
||||
*
|
||||
* Comments:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5G_free_ent_name(H5G_entry_t *ent)
|
||||
{
|
||||
herr_t ret_value=SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_free_ent_name, FAIL);
|
||||
|
||||
/* Check args */
|
||||
assert(ent);
|
||||
|
||||
if ( ent->name )
|
||||
ent->name = H5MM_xfree(ent->name);
|
||||
if ( ent->old_name )
|
||||
ent->old_name = H5MM_xfree(ent->old_name);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5G_insert_name
|
||||
*
|
||||
@ -2548,6 +2728,9 @@ H5G_insert_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name)
|
||||
len1 = HDstrlen(loc->name);
|
||||
len2 = HDstrlen(name);
|
||||
assert(len2>0&&len1>0);
|
||||
if(obj->name)
|
||||
obj->name=H5MM_xfree(obj->name);
|
||||
|
||||
/* this is the root group */
|
||||
if ('/'==loc->name[len1-1])
|
||||
{
|
||||
@ -2849,18 +3032,18 @@ done:
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ");
|
||||
|
||||
H5MM_xfree(new_dst_name);
|
||||
|
||||
H5MM_xfree(new_src_name);
|
||||
|
||||
|
||||
}/*if */
|
||||
}/* if */
|
||||
|
||||
}/*if */
|
||||
}/* if */
|
||||
|
||||
|
||||
} /*for */
|
||||
}/*if */
|
||||
} /* for */
|
||||
|
||||
}/* if */
|
||||
|
||||
|
||||
} /*if */
|
||||
} /* if */
|
||||
|
||||
/* Verify if file IDs refer to the same file */
|
||||
else {
|
||||
|
@ -323,6 +323,10 @@ done:
|
||||
* Quincey Koziol, 2002-7-180
|
||||
* Added dxpl parameter to allow more control over I/O from metadata
|
||||
* cache.
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
@ -397,6 +401,12 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
|
||||
* preempted from the cache.
|
||||
*/
|
||||
if (destroy) {
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
for (i=0; i<sym->nsyms; i++) {
|
||||
H5G_free_ent_name(&(sym->entry[i]));
|
||||
}
|
||||
|
||||
sym->entry = H5FL_ARR_FREE(H5G_entry_t,sym->entry);
|
||||
H5FL_FREE(H5G_node_t,sym);
|
||||
}
|
||||
@ -881,6 +891,10 @@ done:
|
||||
* Modifications:
|
||||
* Robb Matzke, 1999-07-28
|
||||
* The ADDR argument is passed by value.
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
|
||||
* Added `id to name' support.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_ins_t
|
||||
@ -945,6 +959,9 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/,
|
||||
H5HL_remove(f, bt_udata->heap_addr, sn->entry[idx].name_off, HDstrlen(s)+1);
|
||||
H5E_clear(); /*no big deal*/
|
||||
|
||||
/*Free the ID to name buffer */
|
||||
H5G_free_ent_name(sn->entry+idx);
|
||||
|
||||
/* Remove the entry from the symbol table node */
|
||||
if (1==sn->nsyms) {
|
||||
/*
|
||||
|
@ -196,4 +196,7 @@ __DLL__ herr_t H5G_replace_name( int type, H5G_entry_t *loc, const char *src_na
|
||||
const char *dst_name, int op );
|
||||
__DLL__ herr_t H5G_insert_name( H5G_entry_t *loc, H5G_entry_t *obj, const char *name);
|
||||
__DLL__ herr_t H5G_ent_copy( const H5G_entry_t *src, H5G_entry_t *dst );
|
||||
/*Free the ID to name buffer */
|
||||
__DLL__ herr_t H5G_free_grp_name(H5G_t *grp);
|
||||
__DLL__ herr_t H5G_free_ent_name(H5G_entry_t *ent);
|
||||
#endif
|
||||
|
@ -225,7 +225,10 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
|
||||
udata.operation = H5G_OPER_INSERT;
|
||||
udata.name = name;
|
||||
udata.heap_addr = stab.heap_addr;
|
||||
udata.ent = *obj_ent;
|
||||
|
||||
/* Deep copy */
|
||||
H5G_ent_copy(obj_ent, &udata.ent);
|
||||
|
||||
|
||||
/* insert */
|
||||
if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios, &udata) < 0)
|
||||
|
@ -5406,8 +5406,6 @@ done:
|
||||
* Robb Matzke, 20 May 1999
|
||||
* Now able to copy opaque types.
|
||||
*
|
||||
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
|
||||
* Added a deep copy of the symbol table entry
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -5430,11 +5428,6 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
|
||||
|
||||
/* Copy actual information */
|
||||
*new_dt = *old_dt;
|
||||
|
||||
/* Deep copy of the symbol table entry */
|
||||
if (H5G_ent_copy(&(old_dt->ent),&(new_dt->ent))<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
|
||||
|
||||
|
||||
/* Copy parent information */
|
||||
if (new_dt->parent)
|
||||
|
@ -61,14 +61,36 @@ int main( void )
|
||||
H5P_DEFAULT ))<0) goto out;
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gcreate
|
||||
* Test H5Iget_name with H5Gcreate, one group
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
TESTING("H5Iget_name with H5Gcreate");
|
||||
TESTING("H5Iget_name with H5Gcreate, one group");
|
||||
|
||||
/* Create group "g0" in the root group using absolute name */
|
||||
if ((group_id = H5Gcreate( file_id, "/g0", 0 ))<0) goto out;
|
||||
|
||||
/* Get name */
|
||||
if (H5Iget_name( group_id, name, size )<0) goto out;
|
||||
|
||||
/* Verify */
|
||||
if (check_name( name, "/g0" )!=0)
|
||||
goto out;
|
||||
|
||||
/* Close */
|
||||
H5Gclose( group_id );
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gcreate, more than one group
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
TESTING("H5Iget_name with H5Gcreate, more than one group");
|
||||
|
||||
/* Create group "g1" in the root group using absolute name */
|
||||
if ((group_id = H5Gcreate( file_id, "/g1", 0 ))<0) goto out;
|
||||
@ -96,6 +118,7 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gopen
|
||||
*-------------------------------------------------------------------------
|
||||
@ -130,6 +153,8 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Dcreate
|
||||
*-------------------------------------------------------------------------
|
||||
@ -175,6 +200,8 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Dopen
|
||||
*-------------------------------------------------------------------------
|
||||
@ -216,6 +243,7 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with a long path
|
||||
*-------------------------------------------------------------------------
|
||||
@ -309,6 +337,8 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gmove and H5Gopen
|
||||
*-------------------------------------------------------------------------
|
||||
@ -338,6 +368,8 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gmove and H5Dopen
|
||||
*-------------------------------------------------------------------------
|
||||
@ -364,6 +396,8 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gmove and H5Topen
|
||||
*-------------------------------------------------------------------------
|
||||
@ -429,6 +463,7 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Gmove and a long path
|
||||
*-------------------------------------------------------------------------
|
||||
@ -809,6 +844,9 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with a defined type dataset
|
||||
*-------------------------------------------------------------------------
|
||||
@ -877,6 +915,8 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with different files, test1
|
||||
*-------------------------------------------------------------------------
|
||||
@ -1305,6 +1345,8 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Glink hard
|
||||
@ -1346,6 +1388,7 @@ int main( void )
|
||||
PASSED();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Glink symbolic
|
||||
*-------------------------------------------------------------------------
|
||||
@ -1385,6 +1428,8 @@ int main( void )
|
||||
|
||||
PASSED();
|
||||
|
||||
#if 1
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with H5Glink symbolic and move target
|
||||
@ -1577,7 +1622,7 @@ int main( void )
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* Close file */
|
||||
H5Fclose( file_id );
|
||||
|
Loading…
Reference in New Issue
Block a user