summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wong <gtw@flux.utah.edu>2010-11-01 15:02:47 -0600
committerGary Wong <gtw@gnu.org>2010-11-04 21:49:35 -0600
commit3a66e2dea0eab259d3bc024309cd71b854f7c97f (patch)
tree1ff19a0f8b2e8c063eb9de581da7bf5a5b664a5a
parent3912bad35e17c393fbe03f6a1368cc61f3f2e040 (diff)
Fix bug which would miscount table size after insertion failure rehash.
After rehashing, the table size accounts only for the successfully replaced keys, so we need to increment the population by one to reflect the outstanding key still to be inserted.
-rw-r--r--ChangeLog5
-rw-r--r--window-table.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f471c8b..2988097 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-01 Gary Wong <gtw@gnu.org>
+
+ * window-table.c (table_insert_index, stack_insert): Fix rehashing
+ bug which could corrupt table sizes.
+
2010-06-01 Gary Wong <gtw@gnu.org>
* decorate-render.c (query_metrics): Don't try to load metrics
diff --git a/window-table.c b/window-table.c
index 981d6b1..ccdf80f 100644
--- a/window-table.c
+++ b/window-table.c
@@ -165,11 +165,11 @@ static void table_rehash( struct window_table *table, unsigned long hash,
static void table_insert_index( struct window_table *table, xcb_window_t key,
int index ) {
- table->used++;
-
for(;;) {
int i;
+ table->used++;
+
for( i = 0; i < table->max; i++ ) {
int h = table_hash( table->hash, table->n, i & 1, key );
xcb_window_t old_key = table->t[ i & 1 ][ h ].key;
@@ -443,11 +443,11 @@ static void stack_insert( struct window_stack *stack, xcb_window_t window,
xcb_window_t lower_window,
xcb_window_t higher_window ) {
- stack->used++;
-
for(;;) {
int i;
+ stack->used++;
+
for( i = 0; i < stack->max; i++ ) {
int h = table_hash( stack->hash, stack->n, i & 1, window );
xcb_window_t old_window = stack->t[ i & 1 ][ h ].window;