From: Michael Schroeder Date: Tue, 14 Nov 2017 13:33:47 +0000 (+0100) Subject: Add map_invertall function X-Git-Tag: 0.6.31~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c41524bca5493dd1545e256be05d1ddc7563bbc9;p=thirdparty%2Flibsolv.git Add map_invertall function --- diff --git a/src/bitmap.c b/src/bitmap.c index 1bf16667..e004bf2f 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 */ diff --git a/src/bitmap.h b/src/bitmap.h index 5784e6c0..c20b48f1 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -41,6 +41,7 @@ extern void map_free(Map *m); extern void map_and(Map *t, Map *s); extern void map_or(Map *t, Map *s); extern void map_subtract(Map *t, Map *s); +extern void map_invertall(Map *m); static inline void map_empty(Map *m) {