int mm_attrs_commit_all(MMHandleType attrs)
{
- return mmf_attrs_commit(attrs);
+ return mmf_attrs_commit_all(attrs);
}
int mm_attrs_commit(MMHandleType attrs, int index)
{
- mmf_attrs_t *h = (mmf_attrs_t *) attrs;
- mmf_attribute_t *item;
-
- return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
- return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
- item = &h->items[index];
-
- MM_ATTR_ITEM_WRITE_LOCK(item);
-
- mmf_attribute_commit(item);
-
- MM_ATTR_ITEM_WRITE_UNLOCK(item);
-
- return MM_ERROR_NONE;
+ return mmf_attrs_commit(attrs, index, NULL);
}
int mm_attrs_get_type(MMHandleType attrs, int index, MMAttrsType *attrtype)
return 0;
}
-int mmf_attrs_commit(MMHandleType h)
+int mmf_attrs_commit(MMHandleType h, int idx, char **err_attr_name)
{
mmf_attrs_t *attrs = (mmf_attrs_t *)h;
mmf_attribute_t *item = NULL;
- int i;
int ret = 0;
return_val_if_fail(h, -1);
- for (i = 0; i < attrs->count; ++i) {
- item = &attrs->items[i];
+ item = &attrs->items[idx];
- MM_ATTR_ITEM_WRITE_LOCK(item);
-
- if (mmf_attribute_is_modified(item)) {
- if (attrs->commit_func) {
- if (attrs->commit_func(i, item->name,
- &item->tmpval,
- attrs->commit_param)) {
- mmf_attribute_commit(item);
- } else {
- /* without this, there is no way to solve modify when commit_func failed. */
- if (item->flags & MM_ATTRS_FLAG_MODIFIED)
- item->flags ^= MM_ATTRS_FLAG_MODIFIED;
- ret = -1;
- }
- } else {
+ MM_ATTR_ITEM_WRITE_LOCK(item);
+
+ if (mmf_attribute_is_modified(item)) {
+ if (attrs->commit_func) {
+ if (attrs->commit_func(idx,
+ item->name,
+ &item->tmpval,
+ attrs->commit_param)) {
mmf_attribute_commit(item);
+ } else {
+ /* without this, there is no way to solve modify when commit_func failed. */
+ if (item->flags & MM_ATTRS_FLAG_MODIFIED)
+ item->flags ^= MM_ATTRS_FLAG_MODIFIED;
+ ret = -1;
+
+ /* Set Error information */
+ if (err_attr_name)
+ *err_attr_name = strdup(item->name);
}
+ } else {
+ mmf_attribute_commit(item);
}
-
- MM_ATTR_ITEM_WRITE_UNLOCK(item);
}
+ MM_ATTR_ITEM_WRITE_UNLOCK(item);
+
return ret;
}
-int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
+int mmf_attrs_commit_all(MMHandleType h)
{
mmf_attrs_t *attrs = (mmf_attrs_t *)h;
- mmf_attribute_t *item = NULL;
int i;
int ret = 0;
return_val_if_fail(h, -1);
for (i = 0; i < attrs->count; ++i) {
- item = &attrs->items[i];
+ if (mmf_attrs_commit(h, i, NULL) != 0)
+ ret = -1;
+ }
- MM_ATTR_ITEM_WRITE_LOCK(item);
-
- if (mmf_attribute_is_modified(item)) {
- if (attrs->commit_func) {
- if (attrs->commit_func(i, item->name,
- &item->tmpval,
- attrs->commit_param)) {
- mmf_attribute_commit(item);
- } else {
- /* without this, there is no way to solve modify when commit_func failed. */
- if (item->flags & MM_ATTRS_FLAG_MODIFIED)
- item->flags ^= MM_ATTRS_FLAG_MODIFIED;
- ret = -1;
-
- /* Set Error information */
- if (err_attr_name)
- *err_attr_name = strdup(item->name);
-
- MM_ATTR_ITEM_WRITE_UNLOCK(item);
- break;
- }
- } else {
- mmf_attribute_commit(item);
- }
- }
+ return ret;
+}
+
+int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
+{
+ mmf_attrs_t *attrs = (mmf_attrs_t *)h;
+ int i;
+
+ return_val_if_fail(h, -1);
- MM_ATTR_ITEM_WRITE_UNLOCK(item);
+ for (i = 0; i < attrs->count; ++i) {
+ if (mmf_attrs_commit(h, i, err_attr_name) != 0)
+ return -1;
}
- return ret;
+ return 0;
}
int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type)