How to know the number to loop over for h50get_info_by_idx and h5lget_name_by_idx

When looping over h50get_info_by_idx or h5lget_name_by_idx how do I determine the upper bound for idx?

The number of links in a group can be retrieved from the nlinks field in the H5G_info_t structure returned by H5Gget_info ( That’s the smallest “upper bound” for valid positions passed into H5Lget_name_by_index. For H5Oget_info_by_index the story is a little more complicated, because it is possible that some of the links cannot be traversed / resolved to objects (groups, datasets, committed datatypes), e.g., a soft link that has the empty string as its destination.

H5Gget_info (