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
 herr_t
 ss_blob_bind_m(ss_blob_t *blob,                 /* The blob to which memory is associated */
                void *mem,                       /* The memory to which the blob will now point */
                hid_t mtype,                     /* The datatype of each element of the memory. This datatype will be copied
                                                  * into the blob so the caller is free to close the handle at any time. */
                hid_t mspace                     /* The extent of memory and a selection of elements in that memory. This data
                                                  * space will be copied into the blob, so the caller should  close its handle. */
                )
 {
     SS_ENTER(ss_blob_bind_m, herr_t);
     hid_t       hid;

     SS_ASSERT_MEM(blob, ss_blob_t);

     /* Unbind */
     SS_BLOB(blob)->m.mem = NULL;
     if (SS_BLOB(blob)->m.mtype>0) {
         if (H5Tclose(SS_BLOB(blob)->m.mtype)<0) SS_ERROR(HDF5);
         SS_BLOB(blob)->m.mtype = 0;
     }
     if (SS_BLOB(blob)->m.mspace>0) {
         if (H5Sclose(SS_BLOB(blob)->m.mspace)<0) SS_ERROR(HDF5);
         SS_BLOB(blob)->m.mspace = 0;
     }

     /* Bind */
     if (mem) {
         if (ss_blob_ckspace(mspace, SS_MAXDIMS, NULL, NULL, NULL, NULL)<0) SS_ERROR(FAILED);
         SS_BLOB(blob)->m.mem = mem;
         if ((hid=H5Tcopy(mtype))<0) SS_ERROR(HDF5);
         SS_BLOB(blob)->m.mtype = hid;
         if ((hid=ss_blob_normalize(mspace))<0) SS_ERROR(FAILED);
         SS_BLOB(blob)->m.mspace = hid;
     }

  SS_CLEANUP:
     SS_LEAVE(0);
 }