diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | src/H5A.c | 144 | ||||
-rw-r--r-- | src/H5Adeprec.c | 164 | ||||
-rw-r--r-- | src/H5Apkg.h | 7 | ||||
-rw-r--r-- | src/H5Apublic.h | 8 | ||||
-rw-r--r-- | src/H5O.c | 58 | ||||
-rw-r--r-- | src/H5Opublic.h | 1 | ||||
-rwxr-xr-x | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 5 | ||||
-rw-r--r-- | test/links.c | 66 |
10 files changed, 330 insertions, 126 deletions
@@ -409,6 +409,7 @@ ./src/H5timer.c ./src/H5trace.c ./src/H5A.c +./src/H5Adeprec.c ./src/H5Apkg.h ./src/H5Aprivate.h ./src/H5Apublic.h @@ -12,16 +12,21 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5A_PACKAGE /*suppress error about including H5Apkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5A_init_interface -/* Private header files */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ @@ -29,7 +34,35 @@ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SMprivate.h" /* Shared Object Header Messages */ -/* PRIVATE PROTOTYPES */ +/****************/ +/* Local Macros */ +/****************/ + +/* The number of reserved IDs in dataset ID group */ +#define H5A_RESERVED_ATOMS 0 + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Object header iterator callbacks */ +/* Data structure for callback for locating the index by name */ +typedef struct H5A_iter_cb1 { + const char *name; + int idx; +} H5A_iter_cb1; + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + static hid_t H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id); static hid_t H5A_open(H5G_loc_t *loc, unsigned idx, hid_t dxpl_id); @@ -38,17 +71,22 @@ static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_ static int H5A_get_index(H5O_loc_t *loc, const char *name, hid_t dxpl_id); static hsize_t H5A_get_storage_size(const H5A_t *attr); static herr_t H5A_rename(H5O_loc_t *loc, const char *old_name, const char *new_name, hid_t dxpl_id); - -/* Object header iterator callbacks */ -/* Data structure for callback for locating the index by name */ -typedef struct H5A_iter_cb1 { - const char *name; - int idx; -} H5A_iter_cb1; static herr_t H5A_find_idx_by_name(const void *mesg, unsigned idx, void *op_data); -/* The number of reserved IDs in dataset ID group */ -#define H5A_RESERVED_ATOMS 0 + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ /* Declare the free lists for H5A_t's */ H5FL_DEFINE(H5A_t); @@ -57,6 +95,32 @@ H5FL_DEFINE(H5A_t); H5FL_BLK_DEFINE(attr_buf); +/*------------------------------------------------------------------------- + * Function: H5A_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5A_init, FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_init() */ + + /*-------------------------------------------------------------------------- NAME H5A_init_interface -- Initialize interface-specific information @@ -1220,62 +1284,6 @@ H5A_get_storage_size(const H5A_t *attr) } -/*-------------------------------------------------------------------------- - NAME - H5Aget_num_attrs - PURPOSE - Determines the number of attributes attached to an object - USAGE - int H5Aget_num_attrs (loc_id) - hid_t loc_id; IN: Object (dataset or group) to be queried - RETURNS - Number of attributes on success, negative on failure - - DESCRIPTION - This function returns the number of attributes attached to a dataset or - group, 'location_id'. ---------------------------------------------------------------------------*/ -int -H5Aget_num_attrs(hid_t loc_id) -{ - H5O_loc_t *loc = NULL; /* Object location for attribute */ - void *obj = NULL; - int ret_value; - - FUNC_ENTER_API(H5Aget_num_attrs, FAIL) - H5TRACE1("Is","i",loc_id); - - /* check arguments */ - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") - switch (H5I_get_type (loc_id)) { - case H5I_DATASET: - loc = H5D_oloc((H5D_t*)obj); - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") - break; - - case H5I_GROUP: - loc = H5G_oloc((H5G_t*)obj); - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") - } /*lint !e788 All appropriate cases are covered */ - - /* Look up the attribute for the object */ - ret_value = H5O_count(loc, H5O_ATTR_ID, H5AC_ind_dxpl_id); - -done: - FUNC_LEAVE_API(ret_value) -} /* H5Aget_num_attrs() */ - - /*------------------------------------------------------------------------- * Function: H5Arename * diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c new file mode 100644 index 0000000..b2c0b01 --- /dev/null +++ b/src/H5Adeprec.c @@ -0,0 +1,164 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Adeprec.c + * November 27 2006 + * Quincey Koziol <koziol@hdfgroup.org> + * + * Purpose: Deprecated functions from the H5A interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5A_PACKAGE /*suppress error about including H5Apkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5A_init_deprec_interface + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*-------------------------------------------------------------------------- +NAME + H5A_init_deprec_interface -- Initialize interface-specific information +USAGE + herr_t H5A_init_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5A_init() currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5A_init_deprec_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_init_deprec_interface) + + FUNC_LEAVE_NOAPI(H5A_init()) +} /* H5A_init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Aget_num_attrs + PURPOSE + Determines the number of attributes attached to an object + NOTE + Deprecated in favor of H5Oget_info[_by_idx] + USAGE + int H5Aget_num_attrs (loc_id) + hid_t loc_id; IN: Object (dataset or group) to be queried + RETURNS + Number of attributes on success, negative on failure + DESCRIPTION + This function returns the number of attributes attached to a dataset or + group, 'location_id'. +--------------------------------------------------------------------------*/ +int +H5Aget_num_attrs(hid_t loc_id) +{ + H5O_loc_t *loc; /* Object location for attribute */ + void *obj; + int ret_value; + + FUNC_ENTER_API(H5Aget_num_attrs, FAIL) + H5TRACE1("Is","i",loc_id); + + /* check arguments */ + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(NULL == (obj = H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") + switch(H5I_get_type (loc_id)) { + case H5I_DATASET: + if(NULL == (loc = H5D_oloc((H5D_t*)obj))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") + break; + + case H5I_DATATYPE: + if(NULL == (loc = H5T_oloc((H5T_t*)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") + break; + + case H5I_GROUP: + if(NULL == (loc = H5G_oloc((H5G_t*)obj))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") + break; + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") + } /*lint !e788 All appropriate cases are covered */ + + /* Look up the # of attributes for the object */ + if((ret_value = H5O_count(loc, H5O_ATTR_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Aget_num_attrs() */ + diff --git a/src/H5Apkg.h b/src/H5Apkg.h index b8babf9..e01d788 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -66,8 +66,9 @@ H5FL_EXTERN(H5A_t); H5FL_BLK_EXTERN(attr_buf); /* Function prototypes for H5A package scope */ -H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr, unsigned update_flags); -H5_DLL herr_t H5A_free(H5A_t *attr); -H5_DLL herr_t H5A_close(H5A_t *attr); +H5_DLL herr_t H5A_init(void); +H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr, unsigned update_flags); +H5_DLL herr_t H5A_free(H5A_t *attr); +H5_DLL herr_t H5A_close(H5A_t *attr); #endif diff --git a/src/H5Apublic.h b/src/H5Apublic.h index ec9904a..21545ae 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -41,12 +41,18 @@ H5_DLL hid_t H5Aget_type(hid_t attr_id); H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); -H5_DLL int H5Aget_num_attrs(hid_t loc_id); H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data); H5_DLL herr_t H5Adelete(hid_t loc_id, const char *name); +/* Functions and variables defined for compatibility with previous versions + * of the HDF5 API. + * + * Use of these functions and variables is deprecated. + */ +H5_DLL int H5Aget_num_attrs(hid_t loc_id); + #ifdef __cplusplus } #endif @@ -123,8 +123,6 @@ static herr_t H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, static herr_t H5O_reset_real(const H5O_msg_class_t *type, void *native); static void * H5O_copy_real(const H5O_msg_class_t *type, const void *mesg, void *dst); -static int H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, - hid_t dxpl_id); static void *H5O_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id); static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, @@ -1370,8 +1368,11 @@ done: int H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - int ret_value; /* Return value */ + H5O_t *oh = NULL; /* Object header to operate on */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + int acc; /* Count of the message type found */ + unsigned u; /* Local index variable */ + int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_count, FAIL) @@ -1383,46 +1384,6 @@ H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); - /* Call the "real" count routine */ - if((ret_value = H5O_count_real(loc, type, dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to count object header messages") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_count() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_count_real - * - * Purpose: Counts the number of messages in an object header which are a - * certain type. - * - * Return: Success: Number of messages of specified type. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Tuesday, April 21, 1998 - * - *------------------------------------------------------------------------- - */ -static int -H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, hid_t dxpl_id) -{ - H5O_t *oh = NULL; - int acc; - unsigned u; - int ret_value; - - FUNC_ENTER_NOAPI(H5O_count_real, FAIL) - - /* Check args */ - HDassert(loc); - HDassert(loc->file); - HDassert(H5F_addr_defined(loc->addr)); - HDassert(type); - /* Load the object header */ if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") @@ -1436,11 +1397,11 @@ H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, hid_t dxpl_id) ret_value = acc; done: - if (oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) != SUCCEED) + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_count_real() */ +} /* end H5O_count() */ /*------------------------------------------------------------------------- @@ -3909,6 +3870,7 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) oinfo->hdr.nchunks = oh->nchunks; /* Iterate over all the messages, accumulating message size & type information */ + oinfo->num_attrs = 0; oinfo->hdr.meta_space = H5O_SIZEOF_HDR_OH(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); oinfo->hdr.mesg_space = 0; oinfo->hdr.free_space = 0; @@ -3917,6 +3879,10 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { uint64_t type_flag; /* Flag for message type */ + /* Check for attribute message */ + if(H5O_ATTR_ID == curr_msg->type->id) + oinfo->num_attrs++; + /* Accumulate information, based on the type of message */ if(H5O_NULL_ID == curr_msg->type->id) oinfo->hdr.free_space += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; diff --git a/src/H5Opublic.h b/src/H5Opublic.h index b2a9778..4591120 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -87,6 +87,7 @@ typedef struct H5O_info_t { H5O_type_t type; /* Basic object type (group, dataset, etc.) */ unsigned rc; /* Reference count of object */ time_t mtime; /* Modification time */ + hsize_t num_attrs; /* # of attributes attached to object */ struct { unsigned version; /* Version number of header format in file */ unsigned nmesgs; /* Number of object header messages */ diff --git a/src/Makefile.am b/src/Makefile.am index 98103da..298b488 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,7 @@ DISTCLEANFILES=H5pubconf.h # library sources libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ - H5A.c H5AC.c H5B.c H5Bcache.c \ + H5A.c H5Adeprec.c H5AC.c H5B.c H5Bcache.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 912c552..b4a7135 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -81,7 +81,7 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libhdf5_la_LIBADD = am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ - H5timer.lo H5trace.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \ + H5timer.lo H5trace.lo H5A.lo H5Adeprec.lo H5AC.lo H5B.lo H5Bcache.lo \ H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2stat.lo \ H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dcompact.lo H5Dcontig.lo \ H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \ @@ -397,7 +397,7 @@ DISTCLEANFILES = H5pubconf.h # library sources libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ - H5A.c H5AC.c H5B.c H5Bcache.c \ + H5A.c H5Adeprec.c H5AC.c H5B.c H5Bcache.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ @@ -565,6 +565,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5A.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Adeprec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5AC.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2.Plo@am__quote@ diff --git a/test/links.c b/test/links.c index adf4368..c71e1b9 100644 --- a/test/links.c +++ b/test/links.c @@ -8377,6 +8377,7 @@ object_info_check(hid_t main_group_id, hid_t soft_group_id, H5L_index_t idx_type /* Check that the object is the correct one */ if(H5F_addr_ne(oinfo.addr, objno[u])) TEST_ERROR + if(H5F_addr_ne(oinfo.num_attrs, u)) TEST_ERROR /* Query the object's information, by index */ if(H5Oget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &oinfo, H5P_DEFAULT) < 0) TEST_ERROR @@ -8384,11 +8385,13 @@ object_info_check(hid_t main_group_id, hid_t soft_group_id, H5L_index_t idx_type /* Check that the object is the correct one */ if(order == H5_ITER_INC) { if(H5F_addr_ne(oinfo.addr, objno[u])) TEST_ERROR + if(H5F_addr_ne(oinfo.num_attrs, u)) TEST_ERROR } /* end if */ else if(order == H5_ITER_DEC) { unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ if(H5F_addr_ne(oinfo.addr, objno[dec_u])) TEST_ERROR + if(H5F_addr_ne(oinfo.num_attrs, dec_u)) TEST_ERROR } /* end if */ else { /* XXX: What to do about native order? */ @@ -8426,6 +8429,7 @@ object_info(hid_t fapl) hid_t group_id = (-1); /* Group ID */ hid_t soft_group_id = (-1); /* Group ID for soft links */ hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t space_id = (-1); /* Dataspace ID (for attributes) */ H5L_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ hbool_t use_index; /* Use index on creation order values */ @@ -8435,9 +8439,10 @@ object_info(hid_t fapl) char filename[NAME_BUF_SIZE];/* File name */ char objname[NAME_BUF_SIZE]; /* Object name */ char valname[NAME_BUF_SIZE]; /* Link value */ + char attrname[NAME_BUF_SIZE]; /* Attribute name */ haddr_t *objno = NULL; /* Addresses of the objects created */ herr_t ret; /* Generic return value */ - unsigned u; /* Local index variable */ + unsigned u, v; /* Local index variables */ /* Create group creation property list */ if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR @@ -8448,6 +8453,9 @@ object_info(hid_t fapl) /* Allocate object address array */ if(NULL == (objno = HDmalloc(sizeof(haddr_t) * (max_compact * 2)))) TEST_ERROR + /* Create dataspace for attributes */ + if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + /* Loop over operating on different indices on link fields */ for(idx_type = H5L_INDEX_NAME; idx_type <=H5L_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ @@ -8524,6 +8532,7 @@ object_info(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ sprintf(objname, "filler %02u", u); @@ -8535,6 +8544,18 @@ object_info(hid_t fapl) if(H5Oget_info(group_id2, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR objno[u] = oinfo.addr; + /* Create attributes on new object */ + for(v = 0; v < u; v++) { + /* Make name for attribute */ + sprintf(attrname, "attr %02u", v); + + /* Create attribute */ + if((attr_id = H5Acreate(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close attribute */ + if(H5Aclose(attr_id) < 0) TEST_ERROR + } /* end for */ + /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -8559,6 +8580,7 @@ object_info(hid_t fapl) /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ sprintf(objname, "filler %02u", u); @@ -8570,6 +8592,18 @@ object_info(hid_t fapl) if(H5Oget_info(group_id2, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR objno[u] = oinfo.addr; + /* Create attributes on new object */ + for(v = 0; v < u; v++) { + /* Make name for attribute */ + sprintf(attrname, "attr %02u", v); + + /* Create attribute */ + if((attr_id = H5Acreate(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close attribute */ + if(H5Aclose(attr_id) < 0) TEST_ERROR + } /* end for */ + /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -8603,10 +8637,9 @@ object_info(hid_t fapl) } /* end for */ } /* end for */ - /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR - /* Free resources */ + if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if(H5Sclose(space_id) < 0) TEST_ERROR if(objno) HDfree(objno); @@ -8615,6 +8648,7 @@ object_info(hid_t fapl) error: /* Free resources */ H5E_BEGIN_TRY { + H5Sclose(space_id); H5Pclose(gcpl_id); H5Gclose(group_id); H5Gclose(soft_group_id); @@ -8647,14 +8681,19 @@ object_info_old(hid_t fapl) hid_t file_id = (-1); /* File ID */ hid_t group_id = (-1); /* Group ID */ hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t space_id = (-1); /* Dataspace ID (for attributes) */ H5_iter_order_t order; /* Order within in the index */ H5O_info_t oinfo; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ char objname[NAME_BUF_SIZE]; /* Object name */ char valname[NAME_BUF_SIZE]; /* Link value */ + char attrname[NAME_BUF_SIZE]; /* Attribute name */ haddr_t objno[CORDER_NLINKS]; /* Addresses of the objects created */ herr_t ret; /* Generic return value */ - unsigned u; /* Local index variable */ + unsigned u, v; /* Local index variables */ + + /* Create dataspace for attributes */ + if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR /* Loop over operating in different orders */ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { @@ -8692,6 +8731,7 @@ object_info_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ sprintf(objname, "filler %02u", u); @@ -8703,6 +8743,18 @@ object_info_old(hid_t fapl) if(H5Oget_info(group_id2, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR objno[u] = oinfo.addr; + /* Create attributes on new object */ + for(v = 0; v < u; v++) { + /* Make name for attribute */ + sprintf(attrname, "attr %02u", v); + + /* Create attribute */ + if((attr_id = H5Acreate(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Close attribute */ + if(H5Aclose(attr_id) < 0) TEST_ERROR + } /* end for */ + /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -8740,11 +8792,15 @@ object_info_old(hid_t fapl) PASSED(); } /* end for */ + /* Free resources */ + if(H5Sclose(space_id) < 0) TEST_ERROR + return 0; error: /* Free resources */ H5E_BEGIN_TRY { + H5Sclose(space_id); H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); |