[ltrace-commits] 01/02: dict entries lost due to erase

Petr Machata pmachata-guest at moszumanska.debian.org
Wed Jan 7 00:50:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

pmachata-guest pushed a commit to branch master
in repository ltrace.

commit d09f495b220817e34af435f5b4e8b01bd8747890
Author: Faraz Shahbazker <faraz.shahbazker at imgtec.com>
Date:   Mon Jan 5 13:14:46 2015 -0800

    dict entries lost due to erase
---
 dict.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/dict.c b/dict.c
index 236e90e..0bfd552 100644
--- a/dict.c
+++ b/dict.c
@@ -635,10 +635,39 @@ test_erase(void)
 	DICT_DESTROY(&d2, int, int, NULL, NULL, NULL);
 }
 
+static void
+test_erase_find(void)
+{
+	/* Degenerate case for erase followed by find, considering 2 colliding keys.
+	   Erase 1st inserted key, then try finding 2nd.
+	 */
+	struct dict d2;
+	DICT_INIT(&d2, int, int, dict_hash_int_silly, dict_eq_int, NULL);
+	int key;
+	int value;
+
+	key = 0, value = 0;
+	DICT_INSERT(&d2, &key, &value);
+	key = 10, value = 10;
+	DICT_INSERT(&d2, &key, &value);
+
+	key = 10;
+	assert (DICT_FIND_REF(&d2, &key, int) != NULL);
+
+	key = 0;
+	DICT_ERASE(&d2, &key, int, NULL, NULL, NULL);
+
+	key = 10;
+	assert (DICT_FIND_REF(&d2, &key, int) != NULL);
+
+	DICT_DESTROY(&d2, int, int, NULL, NULL, NULL);
+}
+
 int main(int argc, char *argv[])
 {
 	test1();
 	test_erase();
+	test_erase_find();
 	return 0;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git



More information about the ltrace-commits mailing list