summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-09-13 15:44:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-09-13 15:44:56 (GMT)
commit579284f422b6ed25b7a5f4a518c19740fff297c8 (patch)
tree564b2a7b4c13854a19ffaf465f94e6abd52d6340 /hl
parent15d118faedd8e61e8ec2a715cf8fcea5b1afab35 (diff)
downloadhdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.zip
hdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.tar.gz
hdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.tar.bz2
[svn-r14144] Description:
Move H5Gget_objinfo() to deprecated symbols section and retarget internal usage to H5Lget_info()/H5Oget_info(). Misc. other code cleanups... Tested on: FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (kagiso) Linux/64 2.6 (smirom) AIX/32 5.3 (copper) Solaris/32 2.10 (linew) Mac OS X/32 10.4.10 (amazon)
Diffstat (limited to 'hl')
-rw-r--r--hl/src/H5DS.c77
-rw-r--r--hl/src/H5LT.c511
-rw-r--r--hl/src/H5LTprivate.h5
3 files changed, 129 insertions, 464 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 91a4c40..8c10623 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -138,7 +138,7 @@ herr_t H5DSattach_scale(hid_t did,
hobj_ref_t ref_j; /* iterator reference */
hvl_t *buf; /* VL buffer to store in the attribute */
hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
- H5G_stat_t sb1, sb2;
+ H5O_info_t oi1, oi2;
H5I_type_t it1, it2;
int i, len;
int found_ds=0;
@@ -152,15 +152,15 @@ herr_t H5DSattach_scale(hid_t did,
return FAIL;
/* get info for the dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb1)<0)
+ if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0)
return FAIL;
/* same object, not valid */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
return FAIL;
/* get ID type */
@@ -329,18 +329,16 @@ herr_t H5DSattach_scale(hid_t did,
goto out;
/* get info for DS in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0)
+ if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0)
goto out;
/* get info for this DS */
- if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0)
goto out;
/* same object, so this DS scale is already in this DIM IDX */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
- {
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
found_ds = 1;
- }
/* close the dereferenced dataset */
if (H5Dclose(dsid_j)<0)
@@ -596,14 +594,14 @@ herr_t H5DSdetach_scale(hid_t did,
hid_t tid = -1; /* attribute type ID */
hid_t aid = -1; /* attribute ID */
int rank; /* rank of dataset */
- ds_list_t *dsbuf=NULL; /* array of attribute data in the DS pointing to the dataset */
- ds_list_t *dsbufn=NULL; /* array of attribute data in the DS pointing to the dataset */
- hsize_t *dims=NULL; /* dimension of the "REFERENCE_LIST" array */
+ ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ ds_list_t *dsbufn = NULL; /* array of attribute data in the DS pointing to the dataset */
+ hsize_t *dims = NULL; /* dimension of the "REFERENCE_LIST" array */
hobj_ref_t ref; /* reference to the DS */
- hvl_t *buf=NULL; /* VL buffer to store in the attribute */
+ hvl_t *buf = NULL; /* VL buffer to store in the attribute */
unsigned i, j, jj;
- H5G_stat_t sb1, sb2, sb3, sb4;
- int found_dset=0, found_ds=0;
+ H5O_info_t oi1, oi2, oi3, oi4;
+ int found_dset = 0, found_ds = 0;
H5I_type_t it1, it2;
/*-------------------------------------------------------------------------
@@ -615,15 +613,15 @@ herr_t H5DSdetach_scale(hid_t did,
return FAIL;
/* get info for the dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb1)<0)
+ if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0)
return FAIL;
/* same object, not valid */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
return FAIL;
/* get ID type */
@@ -709,20 +707,17 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
/* get info for DS in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0)
+ if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0)
goto out;
/* get info for this DS */
- if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0)
goto out;
/* same object, reset */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
- {
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) {
for(jj=j; jj<buf[idx].len-1; jj++)
- {
((hobj_ref_t *)buf[idx].p)[jj] = ((hobj_ref_t *)buf[idx].p)[jj+1];
- }
buf[idx].len--;
found_ds = 1;
@@ -794,21 +789,17 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
/* get info for dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb3)<0)
+ if(H5Oget_info(did, ".", &oi3, H5P_DEFAULT) < 0)
goto out;
/* get info for this dataset */
- if (H5Gget_objinfo(did_i,".",TRUE,&sb4)<0)
+ if(H5Oget_info(did_i, ".", &oi4, H5P_DEFAULT) < 0)
goto out;
/* same object, reset. we want to detach only for this DIM */
- if (!memcmp(&sb3.fileno, &sb4.fileno, sizeof(sb3.fileno)) && !memcmp(&sb3.objno, &sb4.objno, sizeof(sb3.objno))
- && (int)idx==dsbuf[i].dim_idx)
- {
+ if(oi3.fileno == oi4.fileno && oi3.addr == oi4.addr && (int)idx == dsbuf[i].dim_idx) {
for(jj=i; jj<nelmts-1; jj++)
- {
dsbuf[jj] = dsbuf[jj+1];
- }
nelmts--;
found_dset=1;
@@ -966,7 +957,7 @@ htri_t H5DSis_attached(hid_t did,
hvl_t *buf; /* VL buffer to store in the attribute */
hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
hid_t did_i; /* dataset ID in REFERENCE_LIST */
- H5G_stat_t sb1, sb2, sb3, sb4;
+ H5O_info_t oi1, oi2, oi3, oi4;
H5I_type_t it1, it2;
int i;
int found_dset=0, found_ds=0;
@@ -980,15 +971,15 @@ htri_t H5DSis_attached(hid_t did,
return FAIL;
/* get info for the dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb1)<0)
+ if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0)
return FAIL;
/* same object, not valid */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
return FAIL;
/* get ID type */
@@ -1062,18 +1053,16 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/* get info for DS in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0)
+ if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0)
goto out;
/* get info for this DS */
- if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0)
+ if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0)
goto out;
/* same object */
- if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)))
- {
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
found_ds = 1;
- }
/* close the dereferenced dataset */
if (H5Dclose(dsid_j)<0)
@@ -1150,18 +1139,16 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/* get info for dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb3)<0)
+ if(H5Oget_info(did, ".", &oi3, H5P_DEFAULT) < 0)
goto out;
/* get info for this dataset */
- if (H5Gget_objinfo(did_i,".",TRUE,&sb4)<0)
+ if(H5Oget_info(did_i, ".", &oi4, H5P_DEFAULT) < 0)
goto out;
/* same object */
- if (!memcmp(&sb3.fileno, &sb4.fileno, sizeof(sb3.fileno)) && !memcmp(&sb3.objno, &sb4.objno, sizeof(sb3.objno))
- && (int)idx==dsbuf[i].dim_idx) {
+ if(oi3.fileno == oi4.fileno && oi3.addr == oi4.addr && (int)idx==dsbuf[i].dim_idx)
found_dset=1;
- } /* if */
/* close the dereferenced dataset */
if (H5Dclose(did_i)<0)
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 10977a7..d7f720a 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -38,13 +38,11 @@ int indent = 0;
*
*-------------------------------------------------------------------------
*/
-
-herr_t H5LT_open_id( hid_t loc_id,
- const char *obj_name,
- int obj_type );
-
-herr_t H5LT_close_id( hid_t obj_id,
- int obj_type );
+static herr_t H5LT_get_attribute_mem(hid_t loc_id,
+ const char *obj_name,
+ const char *attr_name,
+ hid_t mem_type_id,
+ void *data);
/*-------------------------------------------------------------------------
*
@@ -1121,16 +1119,10 @@ herr_t H5LTset_attribute_string( hid_t loc_id,
hid_t attr_id;
hid_t obj_id;
int has_attr;
- H5G_stat_t statbuf;
size_t attr_size;
-
- /* Get the type of object */
- if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0)
- return -1;
-
/* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
return -1;
/* Create the attribute */
@@ -1176,14 +1168,14 @@ herr_t H5LTset_attribute_string( hid_t loc_id,
goto out;
/* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
+ if(H5Oclose(obj_id) < 0)
return -1;
return 0;
out:
- H5LT_close_id( obj_id, statbuf.type );
+ H5Oclose(obj_id);
return -1;
}
@@ -1219,14 +1211,9 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id,
hid_t obj_id, sid, attr_id;
hsize_t dim_size=size;
int has_attr;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
/* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
return -1;
/* Create the data space for the attribute. */
@@ -1260,99 +1247,16 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id,
goto out;
/* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
+ if(H5Oclose(obj_id) < 0 )
return -1;
return 0;
out:
- H5LT_close_id( obj_id, statbuf.type );
+ H5Oclose(obj_id);
return -1;
}
-/*-------------------------------------------------------------------------
- * Function: H5LT_open_id
- *
- * Purpose: Private function used by H5LT_set_attribute_*
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5LT_open_id( hid_t loc_id,
- const char *obj_name,
- int obj_type /*basic object type*/ )
-{
- hid_t obj_id = -1;
-
- switch(obj_type) {
- case H5G_DATASET:
- /* Open the dataset. */
- if((obj_id = H5Dopen(loc_id, obj_name)) < 0)
- return -1;
- break;
-
- case H5G_GROUP:
- /* Open the group. */
- if((obj_id = H5Gopen2(loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
- break;
-
- default:
- return -1;
- }
-
- return obj_id;
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5LT_close_id
- *
- * Purpose: Private function used by H5LT_set_attribute_*
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5LT_close_id( hid_t obj_id,
- int obj_type /*basic object type*/ )
-{
- switch ( obj_type )
- {
- case H5G_DATASET:
- /* Close the dataset. */
- if ( H5Dclose( obj_id ) < 0 )
- return -1;
- break;
-
- case H5G_GROUP:
- /* Close the group. */
- if ( H5Gclose( obj_id ) < 0 )
- return -1;
- break;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
/*-------------------------------------------------------------------------
* Function: H5LTset_attribute_char
@@ -1825,21 +1729,16 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id,
{
hid_t attr_id;
hid_t sid;
- H5G_stat_t statbuf;
hid_t obj_id;
- /* Get the type of object */
- if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0)
- return -1;
-
/* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
return -1;
/* Open the attribute. */
if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 )
{
- H5LT_close_id( obj_id, statbuf.type );
+ H5Oclose(obj_id);
return -1;
}
@@ -1860,14 +1759,14 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id,
goto out;;
/* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
+ if(H5Oclose(obj_id) < 0 )
return -1;
return 0;
out:
H5Aclose( attr_id );
- H5LT_close_id( obj_id, statbuf.type );
+ H5Oclose(obj_id);
return -1;
}
@@ -1897,21 +1796,16 @@ herr_t H5LTget_attribute_info( hid_t loc_id,
hid_t attr_id;
hid_t tid;
hid_t sid;
- H5G_stat_t statbuf;
hid_t obj_id;
- /* Get the type of object */
- if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0)
- return -1;
-
/* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
return -1;
/* Open the attribute. */
if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 )
{
- H5LT_close_id( obj_id, statbuf.type );
+ H5Oclose(obj_id);
return -1;
}
@@ -1945,15 +1839,15 @@ herr_t H5LTget_attribute_info( hid_t loc_id,
goto out;
/* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
+ if(H5Oclose(obj_id) < 0 )
return -1;
return 0;
out:
- H5Tclose( tid );
- H5Aclose( attr_id );
- H5LT_close_id( obj_id, statbuf.type );
+ H5Tclose(tid);
+ H5Aclose(attr_id);
+ H5Oclose(obj_id);
return -1;
}
@@ -2695,17 +2589,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id,
const char *attr_name,
char *data )
{
-
/* identifiers */
hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
/* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
+ if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0)
return -1;
/* Get the attribute */
@@ -2713,7 +2601,7 @@ herr_t H5LTget_attribute_string( hid_t loc_id,
return -1;
/* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
+ if(H5Oclose(obj_id) < 0)
return -1;
return 0;
@@ -2742,29 +2630,11 @@ herr_t H5LTget_attribute_char( hid_t loc_id,
const char *attr_name,
char *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_CHAR, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -2789,29 +2659,11 @@ herr_t H5LTget_attribute_uchar( hid_t loc_id,
const char *attr_name,
unsigned char *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_UCHAR, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -2838,29 +2690,11 @@ herr_t H5LTget_attribute_short( hid_t loc_id,
const char *attr_name,
short *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_SHORT, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -2885,29 +2719,11 @@ herr_t H5LTget_attribute_ushort( hid_t loc_id,
const char *attr_name,
unsigned short *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_USHORT, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -2934,29 +2750,11 @@ herr_t H5LTget_attribute_int( hid_t loc_id,
const char *attr_name,
int *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_INT, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -2981,29 +2779,11 @@ herr_t H5LTget_attribute_uint( hid_t loc_id,
const char *attr_name,
unsigned int *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_UINT, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -3030,30 +2810,13 @@ herr_t H5LTget_attribute_long( hid_t loc_id,
const char *attr_name,
long *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_LONG, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
+
/*-------------------------------------------------------------------------
* Function: H5LTget_attribute_long_long
*
@@ -3076,29 +2839,11 @@ herr_t H5LTget_attribute_long_long( hid_t loc_id,
const char *attr_name,
long_long *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_LLONG, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -3124,29 +2869,11 @@ herr_t H5LTget_attribute_ulong( hid_t loc_id,
const char *attr_name,
unsigned long *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_ULONG, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -3174,29 +2901,11 @@ herr_t H5LTget_attribute_float( hid_t loc_id,
const char *attr_name,
float *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_FLOAT, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -3224,29 +2933,11 @@ herr_t H5LTget_attribute_double( hid_t loc_id,
const char *attr_name,
double *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_DOUBLE, data ) < 0 )
- return -1;
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
-
+ return 0;
}
@@ -3275,31 +2966,11 @@ herr_t H5LTget_attribute( hid_t loc_id,
hid_t mem_type_id,
void *data )
{
+ /* Get the attribute */
+ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0)
+ return -1;
- /* identifiers */
- hid_t obj_id;
- H5G_stat_t statbuf;
-
- /* Get the type of object */
- if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0)
- return -1;
-
- /* Open the object */
- if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0)
- return -1;
-
- /* Get the attribute */
- if ( H5LT_get_attribute_mem( obj_id, attr_name, mem_type_id, data ) < 0 )
- {
- H5LT_close_id( obj_id, statbuf.type );
- return -1;
- }
-
- /* Close the object */
- if ( H5LT_close_id( obj_id, statbuf.type ) < 0 )
- return -1;
-
- return 0;
+ return 0;
}
@@ -3328,29 +2999,41 @@ herr_t H5LTget_attribute( hid_t loc_id,
*/
-herr_t H5LT_get_attribute_mem( hid_t obj_id,
+static herr_t H5LT_get_attribute_mem(hid_t loc_id,
+ const char *obj_name,
const char *attr_name,
hid_t mem_type_id,
- void *data )
+ void *data)
{
+ /* identifiers */
+ hid_t obj_id = -1;
+ hid_t attr_id = -1;
- /* identifiers */
- hid_t attr_id;
+ /* Open the object */
+ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ goto out;
- if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 )
- return -1;
+ if((attr_id = H5Aopen_name(obj_id, attr_name)) < 0)
+ goto out;
- if ( H5Aread( attr_id, mem_type_id, data ) < 0 )
- goto out;
+ if(H5Aread(attr_id, mem_type_id, data) < 0)
+ goto out;
- if ( H5Aclose( attr_id ) < 0 )
- return -1;
+ if(H5Aclose(attr_id) < 0)
+ goto out;
+ attr_id = -1;
- return 0;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0)
+ goto out;
+ obj_id = -1;
+
+ return 0;
out:
- H5Aclose( attr_id );
- return -1;
+ if(attr_id > 0)
+ H5Aclose(attr_id);
+ return -1;
}
/*-------------------------------------------------------------------------
diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h
index 51bcbce..c51ee7c 100644
--- a/hl/src/H5LTprivate.h
+++ b/hl/src/H5LTprivate.h
@@ -27,11 +27,6 @@
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LT_get_attribute_mem( hid_t obj_id,
- const char *attr_name,
- hid_t mem_type_id,
- void *data );
-
H5_HLDLL herr_t H5LT_get_attribute_disk( hid_t obj_id,
const char *attr_name,
void *data );