aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-14 18:53:20 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-18 11:26:27 -0600
commit29ec3156ee66b6e2553a0adb2f35cb143edddc5f (patch)
tree32cbacc1ba3a98d50614aac0a976fc53d411378d
parent18dd19a7d9bb90734b5188fd6f53c76bde711e4b (diff)
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 <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--check-qdict.c2
-rw-r--r--qdict.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/check-qdict.c b/check-qdict.c
index c37d448227..f2b4826560 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 ef73265f49..ba8eef09b7 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++;
}
/**