Commit 2e777594 authored by Pekka Pessi's avatar Pekka Pessi

Fixed su_home_auto() problems.

darcs-hash:20051222130717-65a35-44dcbe5a155590818e5646932bb1c9d5936e8bd8.gz
parent 415a5486
......@@ -228,7 +228,7 @@ unsigned su_block_find_collision, su_block_find_collision_used,
static inline su_alloc_t *su_block_find(su_block_t *b, void *p)
{
int h, h0;
unsigned h, h0, probe;
#if SU_ALLOC_STATS
unsigned collision = 0;
......@@ -246,10 +246,12 @@ static inline su_alloc_t *su_block_find(su_block_t *b, void *p)
h = h0 = ((unsigned long)p) % b->sub_n;
probe = (b->sub_n > SUB_P) ? SUB_P : 1;
do {
if (b->sub_nodes[h].sua_data == p)
return &b->sub_nodes[h];
h += SUB_P;
h += probe;
if (h >= b->sub_n)
h -= b->sub_n;
#if SU_ALLOC_STATS
......@@ -266,14 +268,16 @@ static inline su_alloc_t *su_block_find(su_block_t *b, void *p)
static inline su_alloc_t *su_block_add(su_block_t *b, void *p)
{
unsigned h;
unsigned h, probe;
assert(p != NULL);
h = ((unsigned long)p) % b->sub_n;
probe = (b->sub_n > SUB_P) ? SUB_P : 1;
while (b->sub_nodes[h].sua_data) {
h += SUB_P;
h += probe;
if (h >= b->sub_n)
h -= b->sub_n;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment