fx.collections: hashtable: fix handling of existing keys in put()
This commit is contained in:
@@ -282,18 +282,27 @@ static fx_status hashtable_put(
|
|||||||
break;
|
break;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
fx_hashtable_item *item = fx_object_create(FX_TYPE_HASHTABLE_ITEM);
|
fx_hashtable_item *item = hashtable->t_items[index].i_item;
|
||||||
|
struct fx_hashtable_item_p *item_p = NULL;
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return FX_ERR_NO_MEMORY;
|
item = fx_object_create(FX_TYPE_HASHTABLE_ITEM);
|
||||||
|
if (!item) {
|
||||||
|
return FX_ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
item_p = fx_object_get_private(item, FX_TYPE_HASHTABLE_ITEM);
|
||||||
|
|
||||||
|
fx_value_copy(&item_p->i_key, key);
|
||||||
|
|
||||||
|
hashtable->t_items[index].i_item = item;
|
||||||
|
hashtable->t_count++;
|
||||||
|
} else {
|
||||||
|
item_p = fx_object_get_private(item, FX_TYPE_HASHTABLE_ITEM);
|
||||||
|
fx_value_unset(&item_p->i_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fx_hashtable_item_p *item_p
|
|
||||||
= fx_object_get_private(item, FX_TYPE_HASHTABLE_ITEM);
|
|
||||||
fx_value_copy(&item_p->i_key, key);
|
|
||||||
fx_value_copy(&item_p->i_value, value);
|
fx_value_copy(&item_p->i_value, value);
|
||||||
|
|
||||||
hashtable->t_items[index].i_item = item;
|
|
||||||
hashtable->t_count++;
|
|
||||||
return FX_SUCCESS;
|
return FX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user