Fixed off-by-one error in hash table enumerator, which was causing one class to fail to be resolved.

main
theraven 16 years ago
parent 492b2315c1
commit bfbd52709b

@ -66,7 +66,7 @@ libobjc_CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500
# useful on compilers that support C99 (currently only clang), so there is no
# benefit from supporting platforms with no C99 compiler.
libobjc_CFLAGS += -Werror -std=c99 -g -march=native -fexceptions #-fno-inline
libobjc_OBJCFLAGS += -g -std=c99
libobjc_OBJCFLAGS += -g -std=c99 -march=native
libobjc_LDFLAGS += -g -ltoydispatch
libobjc_LIB_DIRS += -L toydispatch/obj

@ -175,15 +175,19 @@ static int PREFIX(_table_resize)(PREFIX(_table) *table)
// Now we make the original table structure point to the new (empty) array.
table->table = newArray;
table->table_size *= 2;
// The table currently has no entries; the copy has them all.
table->table_used = 0;
// Finally, copy everything into the new table
// Note: we should really do this in a background thread. At this stage,
// we can do the updates safely without worrying about read contention.
int copied = 0;
for (uint32_t i=0 ; i<copy->table_size ; i++)
{
MAP_TABLE_VALUE_TYPE value = copy->table[i].value;
if (!MAP_TABLE_VALUE_NULL(value))
{
copied++;
PREFIX(_insert)(table, value);
}
}
@ -318,6 +322,7 @@ static int PREFIX(_insert)(PREFIX(_table) *table,
MAP_UNLOCK();
return PREFIX(_insert)(table, value);
}
fprintf(stderr, "Insert failed\n");
return 0;
}
@ -446,6 +451,7 @@ PREFIX(_next)(PREFIX(_table) *table,
// enumerating
MAP_LOCK();
(*state)->table = table;
(*state)->index = -1;
__sync_fetch_and_add(&table->enumerator_count, 1);
MAP_UNLOCK();
}
@ -465,6 +471,7 @@ PREFIX(_next)(PREFIX(_table) *table,
{
if (!MAP_TABLE_VALUE_NULL((*state)->table->table[(*state)->index].value))
{
(*state)->seen++;
#ifdef MAP_TABLE_ACCESS_BY_REFERENCE
return &(*state)->table->table[(*state)->index].value;
#else

Loading…
Cancel
Save