Skip to content

Commit

Permalink
bitmap: add bm_unset.
Browse files Browse the repository at this point in the history
  • Loading branch information
silentbicycle committed May 22, 2024
1 parent 05786ed commit f01c9a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/adt/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ bm_get(const struct bm *bm, size_t i);
void
bm_set(struct bm *bm, size_t i);

void
bm_unset(struct bm *bm, size_t i);

/* Get a writeable pointer to the Nth word of the char set bitmap,
* or NULL if out of bounds. */
uint64_t *
Expand Down
9 changes: 9 additions & 0 deletions src/adt/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ bm_set(struct bm *bm, size_t i)
u64bitset_set(bm->map, i);
}

void
bm_unset(struct bm *bm, size_t i)
{
assert(bm != NULL);
assert(i <= UCHAR_MAX);

u64bitset_clear(bm->map, i);
}

uint64_t *
bm_nth_word(struct bm *bm, size_t n)
{
Expand Down

0 comments on commit f01c9a2

Please sign in to comment.