X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbitmap.c;h=1bf16667ab08487a75822596b81fe2c720bd8778;hb=a52836206e91b14de83ffa1f9cce7194066f314f;hp=94a88ca0949adc8b585756182e15f70a6ebc48dc;hpb=d35bea4966d425c319901689e5f09025c783c976;p=platform%2Fupstream%2Flibsolv.git diff --git a/src/bitmap.c b/src/bitmap.c index 94a88ca..1bf1666 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -7,7 +7,7 @@ /* * bitmap.c - * + * */ #include @@ -59,16 +59,42 @@ map_grow(Map *m, int n) } } -/* bitwise-ands same-sized maps t and s, stores the result in t. */ +/* bitwise-ands maps t and s, stores the result in t. */ void map_and(Map *t, Map *s) { unsigned char *ti, *si, *end; ti = t->map; si = s->map; - end = ti + t->size; + 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++; +} + +/* 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++; +} + /* EOF */