int
ss_blob_space(ss_blob_t *blob, /* The blob to query */
hsize_t *size, /* OUT: Optional returned size per blob dimension */
hid_t *space /* OUT: Optional returned data space for the blob */
)
{
SS_ENTER(ss_blob_space, int);
int blob_ndims=0, dset_ndims, i;
hsize_t blobsize[SS_MAXDIMS];
const hsize_t *maxdims=NULL;
SS_ASSERT_MEM(blob, ss_blob_t);
if ((dset_ndims=ss_blob_bound_f(blob, NULL, NULL, NULL, NULL, NULL))<0) SS_ERROR(FAILED);
/* Copy the blob dimension sizes from the blob object. The `count' stored in the blob object has one element per dataset
* dimension. To get the blob dimensions we just discard any sizes that are unity. */
for (i=blob_ndims=0; i<dset_ndims; i++) {
if (SS_BLOB(blob)->count[i]>1) {
blobsize[blob_ndims] = SS_BLOB(blob)->count[i];
if (size) size[blob_ndims] = blobsize[blob_ndims];
blob_ndims++;
} else if (0==SS_BLOB(blob)->count[i]) {
blob_ndims = 1;
blobsize[0] = 0;
if (size) size[0] = 0;
maxdims = ss_blob_unlim_g;
break;
}
}
/* Create the data space. Give it the dimensionality and extent of the blob (not the dataset). Data spaces are born with
* the "all" selection. If the blob had any zero size dimensions then treat the blob as a one-dimensional, unlimited space
* whose current size is zero (see also ss_blob_normalize()). */
if (space && (*space=H5Screate_simple(blob_ndims, blobsize, maxdims))<0) SS_ERROR(HDF5);
SS_CLEANUP:
SS_LEAVE(blob_ndims);
}