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_array_put(ss_array_t *array,                 /* The array whose value will be modified. */
              hid_t mtype,                       /* The datatype of the values pointed to by VALUE. If the array contains
                                                  * persistent object links then pass ss_pers_tm (or preferably negative). */
              size_t offset,                     /* The array element number at which to put VALUE. */
              size_t nelmts,                     /* The number of array elements in VALUE. If this is the constant SS_NOSIZE
                                                  * then we assume that VALUE contains enough data to fill up the current size
                                                  * of the array beginning at the specified OFFSET. */
              const void *value                  /* The value to be written into the array. */
              )
 {
     SS_ENTER(ss_array_put, herr_t);
     size_t      mtype_size=0;                   /* Size of MTYPE in bytes */

     if (!array) SS_ERROR_FMT(USAGE, ("no ss_array_t supplied"));

     /* Check requested range of elements against those defined for the array */
     if (offset>array->nelmts)
         SS_ERROR_FMT(DOMAIN, ("starting offset %lu but array has only %lu elements",
                               (unsigned long)offset, (unsigned long)(array->nelmts)));
     if (SS_NOSIZE==nelmts) nelmts = array->nelmts - offset;
     if (offset+nelmts>array->nelmts)
         SS_ERROR_FMT(DOMAIN, ("elements %lu through %lu selected but array has only %lu elements",
                               (unsigned long)offset, (unsigned long)(offset+nelmts-1), (unsigned long)(array->nelmts)));

     /* Make sure array values are in memory. */
     /* ISSUE: there really isn't any point in actually converting the existing values to memory format and initializing the
      *        array's mbuf if we're about to overwrite the whole thing anyway. */
     if (ss_array_cache(array, mtype)<0) SS_ERROR(FAILED);

     /* Copy data from client into array */
     if (0==(mtype_size=H5Tget_size(array->mtype>0?array->mtype:ss_pers_tm))) SS_ERROR(HDF5);
     memcpy((char*)(array->mbuf)+offset*mtype_size, value, nelmts*mtype_size);
     array->dirty = TRUE;

 SS_CLEANUP:
     SS_LEAVE(0);
 }