Skip to content

lf_table_find return reference to cur rather then to prev #1

@kaszub4u

Description

@kaszub4u

int main(int argc, char **argv)
{
int i;
int *data;
marked_ptr_t *prev, cur;
LF_HashTable *table = malloc(sizeof(LF_HashTable));

    for(i = 0; i < 10000; i++){
        data = malloc(sizeof(int));
        *data = i<<1;
        lf_table_put_if_absent(table, (void *)(uintptr_t)(i<<1), data);
    }

    i = 501<<1;
    data = lf_table_find(&table->buckets[HASH(i)], (uintptr_t)i, &prev, &cur);

    printf("%lu, %lu, %lu, size:%d\n", PTR_OF(*prev)->key>>1, PTR_OF(cur)->key>>1, ((Node*)PTR_OF(cur)->next)->key>>1, (int)table->size);


    return 0;

}

output: 501, 501, 500, size:10000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions