mie: attribute: map: implement REPLACE flag in put()
This commit is contained in:
@@ -149,6 +149,7 @@ enum mie_status mie_attribute_map_put(
|
|||||||
struct attribute_map_entry *entry = get_entry(&map->m_entries, name_hash);
|
struct attribute_map_entry *entry = get_entry(&map->m_entries, name_hash);
|
||||||
struct attribute_map_item *item = NULL;
|
struct attribute_map_item *item = NULL;
|
||||||
struct attribute_map_bucket *bucket = NULL;
|
struct attribute_map_bucket *bucket = NULL;
|
||||||
|
enum mie_status status = MIE_SUCCESS;
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
item = create_item(name, name_hash, value);
|
item = create_item(name, name_hash, value);
|
||||||
@@ -162,6 +163,17 @@ enum mie_status mie_attribute_map_put(
|
|||||||
|
|
||||||
if (entry->e_type == ATTRMAP_ENTRY_ITEM) {
|
if (entry->e_type == ATTRMAP_ENTRY_ITEM) {
|
||||||
item = (struct attribute_map_item *)entry;
|
item = (struct attribute_map_item *)entry;
|
||||||
|
if (!strcmp(item->i_name, name)) {
|
||||||
|
status = MIE_ERR_NAME_EXISTS;
|
||||||
|
|
||||||
|
if (flags & MIE_ATTRMAP_F_REPLACE) {
|
||||||
|
item->i_value = value;
|
||||||
|
status = MIE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
bucket = convert_item_to_bucket(map, item);
|
bucket = convert_item_to_bucket(map, item);
|
||||||
} else {
|
} else {
|
||||||
bucket = (struct attribute_map_bucket *)entry;
|
bucket = (struct attribute_map_bucket *)entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user