summaryrefslogtreecommitdiff
path: root/src/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bitmap.c')
-rw-r--r--src/bitmap.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/bitmap.c b/src/bitmap.c
index 1bf1666..e004bf2 100644
--- a/src/bitmap.c
+++ b/src/bitmap.c
@@ -63,38 +63,48 @@ map_grow(Map *m, int n)
void
map_and(Map *t, Map *s)
{
- unsigned char *ti, *si, *end;
- ti = t->map;
- si = s->map;
- end = ti + (t->size < s->size ? t->size : s->size);
- while (ti < end)
- *ti++ &= *si++;
+ unsigned char *ti, *si, *end;
+ ti = t->map;
+ si = s->map;
+ end = ti + (t->size < s->size ? t->size : s->size);
+ while (ti < end)
+ *ti++ &= *si++;
}
/* bitwise-ors maps t and s, stores the result in t. */
void
map_or(Map *t, Map *s)
{
- unsigned char *ti, *si, *end;
- if (t->size < s->size)
- map_grow(t, s->size << 3);
- ti = t->map;
- si = s->map;
- end = ti + (t->size < s->size ? t->size : s->size);
- while (ti < end)
- *ti++ |= *si++;
+ unsigned char *ti, *si, *end;
+ if (t->size < s->size)
+ map_grow(t, s->size << 3);
+ ti = t->map;
+ si = s->map;
+ end = ti + (t->size < s->size ? t->size : s->size);
+ while (ti < end)
+ *ti++ |= *si++;
}
/* remove all set bits in s from t. */
void
map_subtract(Map *t, Map *s)
{
- unsigned char *ti, *si, *end;
- ti = t->map;
- si = s->map;
- end = ti + (t->size < s->size ? t->size : s->size);
- while (ti < end)
- *ti++ &= ~*si++;
+ unsigned char *ti, *si, *end;
+ ti = t->map;
+ si = s->map;
+ end = ti + (t->size < s->size ? t->size : s->size);
+ while (ti < end)
+ *ti++ &= ~*si++;
+}
+
+void
+map_invertall(Map *m)
+{
+ unsigned char *ti, *end;
+ ti = m->map;
+ end = ti + m->size;
+ while (ti < end)
+ *ti++ ^= 0xff;
}
/* EOF */