Skip to content

Commit

Permalink
Merge pull request #1 from oavdeev/j128m_iter_minimal
Browse files Browse the repository at this point in the history
j128m_del fix: update second level judy map pointer after deleting an item
  • Loading branch information
knutin committed Jul 2, 2016
2 parents dc7b1df + 6ab840a commit 281771e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 281771e

Please sign in to comment.