From b94a9f2101683888218cbf4de9be2139b3816403 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 6 Jul 2009 14:11:08 -0700 Subject: More documentation, tidying up, etc. --- upb_table.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'upb_table.c') diff --git a/upb_table.c b/upb_table.c index d53ab1c..bad0b23 100644 --- a/upb_table.c +++ b/upb_table.c @@ -77,8 +77,12 @@ static uint32_t empty_intbucket(struct upb_inttable *table) return 0; } +/* The insert routines have a lot more code duplication between int/string + * variants than I would like, but there's just a bit too much that varies to + * parameterize them. */ static void intinsert(struct upb_inttable *t, struct upb_inttable_entry *e) { + assert(upb_inttable_lookup(t, e->key, t->t.entry_size) == NULL); uint32_t bucket = upb_inttable_bucket(t, e->key); struct upb_inttable_entry *table_e = intent(t, bucket); if(table_e->key != EMPTYENT) { /* Collision. */ @@ -110,6 +114,7 @@ static void intinsert(struct upb_inttable *t, struct upb_inttable_entry *e) } memcpy(table_e, e, t->t.entry_size); table_e->next = UPB_END_OF_CHAIN; + assert(upb_inttable_lookup(t, e->key, t->t.entry_size) == table_e); } void upb_inttable_insert(struct upb_inttable *t, struct upb_inttable_entry *e) @@ -141,6 +146,7 @@ static uint32_t empty_strbucket(struct upb_strtable *table) static void strinsert(struct upb_strtable *t, struct upb_strtable_entry *e) { + assert(upb_strtable_lookup(t, &e->key) == NULL); uint32_t bucket = strtable_bucket(t, &e->key); struct upb_strtable_entry *table_e = strent(t, bucket); if(table_e->key.byte_len != 0) { /* Collision. */ -- cgit v1.2.3