1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 herr_t
 ss_blob_write1(ss_blob_t *blob,                 /* The blob for which data is written. This blob must be bound to both memory
                                                  * and a dataset */
                hsize_t offset,                  /* Offset into the blob data for the first element to be written. */
                hsize_t nelmts,                  /* Number of consecutive elements to be written. */
                unsigned flags,                  /* See ss_blob_write(). */
                ss_prop_t *props                 /* See [Blob Properties]. */
                )
 {
     SS_ENTER(ss_blob_write1, herr_t);
     hid_t       iospace=-1;
     int         ndims;

     SS_ASSERT_MEM(blob, ss_blob_t);
     if ((ndims=ss_blob_space(blob, NULL, &iospace))<0) SS_ERROR(FAILED);
     if (1!=ndims && 0!=ndims) SS_ERROR_FMT(USAGE, ("blob is not one-dimensional or scalar"));

     /* Select the elements of the `iospace'. Even if `nelmts' is zero we still have to call ss_blob_write() for some side
      * effects like for the SS_BLOB_UNBIND bit flag. */
     if (0==ndims) {
         SS_ASSERT(0==nelmts || 1==nelmts);
         SS_ASSERT(0==offset || 0==nelmts);
         if (0==nelmts) {
             if (H5Sselect_none(iospace)<0) SS_ERROR(HDF5);
         } else {
             if (H5Sselect_all(iospace)<0) SS_ERROR(HDF5);
         }
     } else {
         if (H5Sselect_slab(iospace, H5S_SELECT_SET, (hsize_t)0, &offset, &nelmts)<0) SS_ERROR(HDF5);
     }

     /* The actual write */
     if (ss_blob_write(blob, iospace, flags, props)<0) SS_ERROR(FAILED);

     /* Successful cleanup */
     if (H5Sclose(iospace)<0) SS_ERROR(HDF5);
     iospace = -1;

  SS_CLEANUP:
     if (iospace>0) H5Sclose(iospace);

     SS_LEAVE(0);
 }