summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2016-04-03 05:45:31 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2016-11-29 23:42:32 (GMT)
commitda0243af3e3a23fbbf36096e6c672d66c932d31c (patch)
treef3e736e2895c3b2d2128b8789f111058d2dcfc77 /examples
parentf534dde4dc8a9fb76a5cb1ef9eddc297c084da52 (diff)
downloadhdf5-da0243af3e3a23fbbf36096e6c672d66c932d31c.zip
hdf5-da0243af3e3a23fbbf36096e6c672d66c932d31c.tar.gz
hdf5-da0243af3e3a23fbbf36096e6c672d66c932d31c.tar.bz2
Fix examples after H5R changes
Diffstat (limited to 'examples')
-rw-r--r--examples/h5_ref2reg.c28
-rw-r--r--examples/h5_reference.c23
2 files changed, 30 insertions, 21 deletions
diff --git a/examples/h5_ref2reg.c b/examples/h5_ref2reg.c
index c4e8d3d..d6c899a 100644
--- a/examples/h5_ref2reg.c
+++ b/examples/h5_ref2reg.c
@@ -44,8 +44,8 @@ int main(void)
int rank = 2;
int rankr =1;
herr_t status;
- hdset_reg_ref_t ref[2];
- hdset_reg_ref_t ref_out[2];
+ href_t ref[2];
+ href_t ref_out[2];
int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}};
int data_out[2][9] = {{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0}};
hsize_t start[2];
@@ -81,7 +81,7 @@ int main(void)
/*
* Dataset with references.
*/
- dsetr_id = H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dsetr_id = H5Dcreate2(file_id, dsetnamer, H5T_STD_REF_REG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/*
* Create a reference to the hyperslab.
@@ -91,19 +91,19 @@ int main(void)
count[0] = 2;
count[1] = 3;
status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL);
- status = H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
+ ref[0] = H5Rcreate_region(file_id, dsetnamev, space_id);
/*
* Create a reference to elements selection.
*/
status = H5Sselect_none(space_id);
status = H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord);
- status = H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id);
+ ref[1] = H5Rcreate_region(file_id, dsetnamev, space_id);
/*
* Write dataset with the references.
*/
- status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref);
+ status = H5Dwrite(dsetr_id, H5T_STD_REF_REG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref);
/*
* Close all objects.
@@ -111,6 +111,8 @@ int main(void)
status = H5Sclose(space_id);
status = H5Sclose(spacer_id);
status = H5Dclose(dsetr_id);
+ status = H5Rdestroy(ref[0]);
+ status = H5Rdestroy(ref[1]);
status = H5Fclose(file_id);
/*
@@ -124,18 +126,18 @@ int main(void)
*/
dsetr_id = H5Dopen2(file_id, dsetnamer, H5P_DEFAULT);
- status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL,
+ status = H5Dread(dsetr_id, H5T_STD_REF_REG, H5S_ALL, H5S_ALL,
H5P_DEFAULT, ref_out);
/*
* Dereference the first reference.
*/
- dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[0]);
+ dsetv_id = H5Rget_object(dsetr_id, H5P_DEFAULT, ref_out[0]);
/*
* Get name of the dataset the first region reference points to
* using H5Rget_name
*/
- name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, 10);
+ name_size1 = H5Rget_obj_name(dsetr_id, ref_out[0], (char*)buf1, 10);
printf(" Dataset's name (returned by H5Rget_name) the reference points to is %s, name length is %d\n", buf1, (int)name_size1);
/*
* Get name of the dataset the first region reference points to
@@ -144,7 +146,7 @@ int main(void)
name_size2 = H5Iget_name(dsetv_id, (char*)buf2, 10);
printf(" Dataset's name (returned by H5Iget_name) the reference points to is %s, name length is %d\n", buf2, (int)name_size2);
- space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION,&ref_out[0]);
+ space_id = H5Rget_region(dsetr_id, ref_out[0]);
/*
* Read and display hyperslab selection from the dataset.
@@ -177,8 +179,8 @@ int main(void)
/*
* Dereference the second reference.
*/
- dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[1]);
- space_id = H5Rget_region(dsetv_id, H5R_DATASET_REGION,&ref_out[1]);
+ dsetv_id = H5Rget_object(dsetr_id, H5P_DEFAULT, ref_out[1]);
+ space_id = H5Rget_region(dsetv_id, ref_out[1]);
/*
* Read selected data from the dataset.
@@ -201,6 +203,8 @@ int main(void)
status = H5Sclose(space_id);
status = H5Dclose(dsetv_id);
status = H5Dclose(dsetr_id);
+ status = H5Rdestroy(ref_out[0]);
+ status = H5Rdestroy(ref_out[1]);
status = H5Fclose(file_id);
return 0;
diff --git a/examples/h5_reference.c b/examples/h5_reference.c
index 38e6146..345e804 100644
--- a/examples/h5_reference.c
+++ b/examples/h5_reference.c
@@ -38,8 +38,8 @@ main(void) {
H5O_type_t obj_type;
herr_t status;
- hobj_ref_t *wbuf; /* buffer to write to disk */
- hobj_ref_t *rbuf; /* buffer to read from disk */
+ href_t *wbuf; /* buffer to write to disk */
+ href_t *rbuf; /* buffer to read from disk */
hsize_t dim_r[1];
@@ -74,15 +74,15 @@ main(void) {
/*
* Allocate write and read buffers.
*/
- wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
- rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2);
+ wbuf = (href_t *)malloc(sizeof(href_t) * 2);
+ rbuf = (href_t *)malloc(sizeof(href_t) * 2);
/*
* Create references to the group "A" and dataset "B"
* and store them in the wbuf.
*/
- H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, (hid_t)-1);
- H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, (hid_t)-1);
+ wbuf[0] = H5Rcreate_object(fid, "A");
+ wbuf[1] = H5Rcreate_object(fid, "B");
/*
* Write dataset R using default transfer properties.
@@ -101,6 +101,9 @@ main(void) {
H5Sclose(sid_r);
H5Dclose(did_r);
+ H5Rdestroy(wbuf[0]);
+ H5Rdestroy(wbuf[1]);
+
H5Fclose(fid);
/*
@@ -117,18 +120,18 @@ main(void) {
/*
* Find the type of referenced objects.
*/
- status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[0], &obj_type);
+ status = H5Rget_obj_type(did_r, rbuf[0], &obj_type);
if(obj_type == H5O_TYPE_GROUP)
printf("First dereferenced object is a group. \n");
- status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[1], &obj_type);
+ status = H5Rget_obj_type(did_r, rbuf[1], &obj_type);
if(obj_type == H5O_TYPE_DATASET)
printf("Second dereferenced object is a dataset. \n");
/*
* Get datatype of the dataset "B"
*/
- did_b = H5Rdereference2(did_r, H5P_DEFAULT, H5R_OBJECT, &rbuf[1]);
+ did_b = H5Rget_object(did_r, H5P_DEFAULT, rbuf[1]);
tid_b = H5Dget_type(did_b);
if(H5Tequal(tid_b, H5T_NATIVE_FLOAT))
printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n");
@@ -141,6 +144,8 @@ main(void) {
H5Dclose(did_b);
H5Tclose(tid_b);
H5Fclose(fid);
+ H5Rdestroy(rbuf[0]);
+ H5Rdestroy(rbuf[1]);
free(rbuf);
free(wbuf);