Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

j128m_del fix: update second level judy map pointer after deleting an item #1

Merged
merged 1 commit into from
Jul 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/judy_128_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Word_t *j128m_get(const struct judy_128_map *j128m, __uint128_t key)
return NULL;
}

int j128m_del(const struct judy_128_map *j128m, __uint128_t key)
int j128m_del(struct judy_128_map *j128m, __uint128_t key)
{
uint64_t hi_key = (key >> 64) & UINT64_MAX;
uint64_t lo_key = key & UINT64_MAX;
Expand All @@ -72,8 +72,12 @@ int j128m_del(const struct judy_128_map *j128m, __uint128_t key)
JLD(rc, lo_map, lo_key);
int num_left;
JLC(num_left, lo_map, 0, -1);
if (num_left == 0)
if (num_left == 0) {
JLD(rc, j128m->hi_map, hi_key);
}
else {
*(Pvoid_t*)hi_ptr = lo_map;
}
}

return rc;
Expand Down
2 changes: 1 addition & 1 deletion src/judy_128_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Word_t *j128m_insert(struct judy_128_map *j128m, __uint128_t key);

Word_t *j128m_get(const struct judy_128_map *j128m, __uint128_t key);

int j128m_del(const struct judy_128_map *j128m, __uint128_t key);
int j128m_del(struct judy_128_map *j128m, __uint128_t key);

void j128m_find(const struct judy_128_map *j128m, PWord_t *pv, __uint128_t *key);

Expand Down