提交 29ec3156 编写于 作者: L Luiz Capitulino 提交者: Anthony Liguori

QDict: Fix size update

Key replacement should not update the dictionary's size.

This commit also adds a test for the bug.
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 18dd19a7
...@@ -205,6 +205,8 @@ START_TEST(qdict_put_exists_test) ...@@ -205,6 +205,8 @@ START_TEST(qdict_put_exists_test)
value = qdict_get_int(tests_dict, key); value = qdict_get_int(tests_dict, key);
fail_unless(value == 2); fail_unless(value == 2);
fail_unless(qdict_size(tests_dict) == 1);
} }
END_TEST END_TEST
......
...@@ -122,9 +122,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) ...@@ -122,9 +122,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
/* allocate a new entry */ /* allocate a new entry */
entry = alloc_entry(key, value); entry = alloc_entry(key, value);
QLIST_INSERT_HEAD(&qdict->table[hash], entry, next); QLIST_INSERT_HEAD(&qdict->table[hash], entry, next);
qdict->size++;
} }
qdict->size++;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册