2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
21 map_init(Map *m, int n)
23 m->size = (n + 7) >> 3;
24 m->map = m->size ? solv_calloc(m->size, 1) : 0;
31 m->map = solv_free(m->map);
35 /* copy constructor t <- s */
37 map_init_clone(Map *t, Map *s)
42 t->map = solv_malloc(s->size);
43 memcpy(t->map, s->map, s->size);
51 map_grow(Map *m, int n)
56 m->map = solv_realloc(m->map, n);
57 memset(m->map + m->size, 0, n - m->size);
62 /* bitwise-ands maps t and s, stores the result in t. */
64 map_and(Map *t, Map *s)
66 unsigned char *ti, *si, *end;
69 end = ti + (t->size < s->size ? t->size : s->size);
74 /* bitwise-ors maps t and s, stores the result in t. */
76 map_or(Map *t, Map *s)
78 unsigned char *ti, *si, *end;
79 if (t->size < s->size)
80 map_grow(t, s->size << 3);
83 end = ti + (t->size < s->size ? t->size : s->size);
88 /* remove all set bits in s from t. */
90 map_subtract(Map *t, Map *s)
92 unsigned char *ti, *si, *end;
95 end = ti + (t->size < s->size ? t->size : s->size);