diff options
Diffstat (limited to 'src/H5R.c')
-rw-r--r-- | src/H5R.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -211,11 +211,11 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 if(NULL == (buf = H5MM_malloc((size_t)buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Serialize information for dataset OID */ + /* Serialize information for dataset OID into heap buffer */ p = (uint8_t *)buf; H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr); - /* Serialize the selection */ + /* Serialize the selection into heap buffer */ if(H5S_SELECT_SERIALIZE(space, p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") @@ -829,15 +829,26 @@ H5R_get_name(H5F_t *f, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, case H5R_DATASET_REGION: { - const uint8_t *p; /* Pointer to reference to decode */ + const hdset_reg_ref_t *ref = (const hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ + H5HG_t hobjid; /* Heap object ID */ + uint8_t *buf; /* Buffer to store serialized selection in */ + const uint8_t *p; /* Pointer to OID to store */ - /* Skip over the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - p += H5F_SIZEOF_ADDR(f); - p += 4; + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)ref; + H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); + INT32DECODE(p, hobjid.idx); + + /* Get the dataset region from the heap (allocate inside routine) */ + if((buf = H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") /* Get the object oid for the dataset */ - H5F_addr_decode(oloc.file, &p, &oloc.addr); + p = buf; + H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + + /* Free the buffer allocated in H5HG_read() */ + H5MM_xfree(buf); } /* end case */ break; |