herr_t
ss_prop_add(ss_prop_t *prop, /* property list to which is added a property */
const char *name, /* name of property to add */
hid_t type, /* datatype for stored property value */
const void *value /* optional initial property value */
)
{
SS_ENTER(ss_prop_add, herr_t);
size_t offset;
SS_ASSERT_TYPE(prop, ss_prop_t);
if (!prop->appendable) SS_ERROR(PERM);
if (prop->type<=0) {
if ((prop->type=H5Tcreate(H5T_COMPOUND, H5Tget_size(type)))<0) SS_ERROR(HDF5);
offset = 0;
} else {
if (0==(offset=H5Tget_size(prop->type))) SS_ERROR(HDF5);
if (H5Tset_size(prop->type, offset+H5Tget_size(type))<0) SS_ERROR(HDF5);
}
if (NULL==(prop->values=realloc(prop->values, H5Tget_size(prop->type)))) SS_ERROR(RESOURCE);
if (H5Tinsert(prop->type, name, offset, type)<0) SS_ERROR(HDF5);
if (value) {
memcpy((char*)(prop->values)+offset, value, H5Tget_size(type));
} else {
memset((char*)(prop->values)+offset, 0, H5Tget_size(type));
}
SS_CLEANUP:
SS_LEAVE(0);
}