summaryrefslogtreecommitdiff
path: root/mm_attrs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm_attrs.c')
-rw-r--r--mm_attrs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/mm_attrs.c b/mm_attrs.c
index be935a3..fefd2d9 100644
--- a/mm_attrs.c
+++ b/mm_attrs.c
@@ -227,18 +227,18 @@ int mm_attrs_set_string(MMHandleType h, int idx, const char *string, int size)
mmf_attrs_t *attrs = (mmf_attrs_t *) h;
return_val_if_fail(attrs && idx >= 0 && idx < attrs->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
- mmf_attribute_t *item = &attrs->items[idx];
+ mmf_attribute_t *item = &attrs->items[idx];
return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
- MM_ATTRS_WRITE_LOCK(attrs);
+ MM_ATTR_ITEM_WRITE_LOCK(item);
if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE))
{
int ret = 0;
ret = mmf_attribute_set_string(item, string, size);
- MM_ATTRS_WRITE_UNLOCK(attrs);
+ MM_ATTR_ITEM_WRITE_UNLOCK(item);
if (ret == 0)
return MM_ERROR_NONE;
@@ -246,7 +246,7 @@ int mm_attrs_set_string(MMHandleType h, int idx, const char *string, int size)
return MM_ERROR_COMMON_INVALID_ARGUMENT;
}
- MM_ATTRS_WRITE_UNLOCK(attrs);
+ MM_ATTR_ITEM_WRITE_UNLOCK(item);
return MM_ERROR_COMMON_INVALID_PERMISSION;
}
@@ -255,19 +255,22 @@ int mm_attrs_set_string(MMHandleType h, int idx, const char *string, int size)
int mm_attrs_get_string(MMHandleType h, int idx, char **sval, int *size)
{
mmf_attrs_t *attrs = (mmf_attrs_t *) h;
+ mmf_attribute_t *item = NULL;
return_val_if_fail(attrs && idx >= 0 && idx < attrs->count && sval, MM_ERROR_COMMON_INVALID_ARGUMENT);
- MM_ATTRS_WRITE_LOCK(attrs);
+ item = &attrs->items[idx];
- if (!(attrs->items[idx].flags & MM_ATTRS_FLAG_READABLE)) {
+ MM_ATTR_ITEM_WRITE_LOCK(item);
+
+ if (!(item->flags & MM_ATTRS_FLAG_READABLE)) {
//mmf_debug(MMF_DEBUG_LOG, "Access denied.\n");
- MM_ATTRS_WRITE_UNLOCK(attrs);
+ MM_ATTR_ITEM_WRITE_UNLOCK(item);
return MM_ERROR_COMMON_INVALID_PERMISSION;
}
- *sval = mmf_value_get_string(&attrs->items[idx].value,size);
+ *sval = mmf_value_get_string(&item->value, size);
- MM_ATTRS_WRITE_UNLOCK(attrs);
+ MM_ATTR_ITEM_WRITE_UNLOCK(item);
return MM_ERROR_NONE;
}