From: Luiz Capitulino Date: Mon, 14 Dec 2009 20:53:20 +0000 (-0200) Subject: QDict: Fix size update X-Git-Tag: v0.12.0~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5238ac21b82f92ab68ee4877a6a7cdfa0bb2605;p=thirdparty%2Fqemu.git 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: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit 29ec3156ee66b6e2553a0adb2f35cb143edddc5f) --- diff --git a/check-qdict.c b/check-qdict.c index c37d4482279..f2b4826560a 100644 --- a/check-qdict.c +++ b/check-qdict.c @@ -205,6 +205,8 @@ START_TEST(qdict_put_exists_test) value = qdict_get_int(tests_dict, key); fail_unless(value == 2); + + fail_unless(qdict_size(tests_dict) == 1); } END_TEST diff --git a/qdict.c b/qdict.c index ef73265f49f..ba8eef09b7e 100644 --- a/qdict.c +++ b/qdict.c @@ -122,9 +122,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) /* allocate a new entry */ entry = alloc_entry(key, value); QLIST_INSERT_HEAD(&qdict->table[hash], entry, next); + qdict->size++; } - - qdict->size++; } /**