Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates the size hint type for group creation
Browse files Browse the repository at this point in the history
derobins committed Apr 30, 2021

Unverified

The email in this signature doesn’t match the committer email.
1 parent 7a6ee4e commit 17fc91e
Showing 4 changed files with 9 additions and 22 deletions.
9 changes: 3 additions & 6 deletions src/H5Gdeprec.c
Original file line number Diff line number Diff line change
@@ -142,9 +142,8 @@ H5G_map_obj_type(H5O_type_t obj_type)
* and it's object ID is returned.
*
* The SIZE_HINT parameter specifies how much file space to reserve
* to store the names that will appear in this group. This number
* must be less than or equal to UINT32_MAX. If zero is supplied
* for the SIZE_HINT then a default size is chosen.
* to store the names that will appear in this group. If zero is
* supplied for the SIZE_HINT then a default size is chosen.
*
* Note: Deprecated in favor of H5Gcreate2
*
@@ -174,8 +173,6 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
/* Check arguments */
if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name given")
if (size_hint > UINT32_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "size_hint cannot be larger than UINT32_MAX")

/* Check if we need to create a non-standard GCPL */
if (size_hint > 0) {
@@ -199,7 +196,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get group info")

/* Set the non-default local heap size hint */
H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t);
ginfo.lheap_size_hint = size_hint;
if (H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info")
}
3 changes: 1 addition & 2 deletions src/H5Gpublic.h
Original file line number Diff line number Diff line change
@@ -592,8 +592,7 @@ typedef struct H5G_stat_t {
* group, is not limited.
*
* \p size_hint is a hint for the number of bytes to reserve to store
* the names which will be eventually added to the new group. This
* value must be between 0 and UINT32_MAX (inclusive). If this
* the names which will be eventually added to the new group. If this
* parameter is zero, a default value will be used.
*
* The return value is a group identifier for the open group. This
2 changes: 1 addition & 1 deletion src/H5Oprivate.h
Original file line number Diff line number Diff line change
@@ -684,7 +684,7 @@ typedef struct H5O_bogus_t {
*/
typedef struct H5O_ginfo_t {
/* "Old" format group info (not stored) */
uint32_t lheap_size_hint; /* Local heap size hint */
size_t lheap_size_hint; /* Local heap size hint */

/* "New" format group info (stored) */

17 changes: 4 additions & 13 deletions test/tmisc.c
Original file line number Diff line number Diff line change
@@ -4088,22 +4088,13 @@ test_misc23(void)
H5E_END_TRY;
VERIFY(tmp_id, FAIL, "H5Gcreate1");

/* Make sure that size_hint values that can't fit into a 32-bit
* unsigned integer are rejected. Only necessary on systems where
* size_t is a 64-bit type.
*/
if (SIZE_MAX > UINT32_MAX) {
H5E_BEGIN_TRY
{
tmp_id = H5Gcreate1(file_id, "/size_hint_too_large", SIZE_MAX);
}
H5E_END_TRY;
VERIFY(tmp_id, FAIL, "H5Gcreate1");
}

tmp_id = H5Gcreate1(file_id, "/A/grp", (size_t)0);
CHECK(tmp_id, FAIL, "H5Gcreate1");

/* Check that the largest size hint is acceptable */
tmp_id = H5Gcreate1(file_id, "/enormous_size_hint", SIZE_MAX);
CHECK(tmp_id, FAIL, "H5Gcreate1");

status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");

0 comments on commit 17fc91e

Please sign in to comment.