#include "bitmap.h"
#include "util.h"
+/* constructor */
void
map_init(Map *m, int n)
{
m->map = n ? sat_calloc(m->size, 1) : 0;
}
-// free space allocated
+/* destructor */
void
map_free(Map *m)
{
m->size = 0;
}
-// copy t <- s
+/* copy constructor t <- s */
void
map_init_clone(Map *t, Map *s)
{
memcpy(t->map, s->map, t->size);
}
-// EOF
+/* grow a map */
+void
+map_grow(Map *m, int n)
+{
+ n = (n + 7) >> 3;
+ if (m->size < n)
+ {
+ m->map = sat_realloc(m->map, n);
+ memset(m->map + m->size, 0, n - m->size);
+ m->size = n;
+ }
+}
+
+/* EOF */
extern void map_init(Map *m, int n);
extern void map_init_clone(Map *t, Map *s);
+extern void map_grow(Map *m, int n);
extern void map_free(Map *m);
#endif /* SATSOLVER_BITMAP_H */
#include "util.h"
void
+queue_init(Queue *q)
+{
+ q->alloc = q->elements = 0;
+ q->count = q->left = 0;
+}
+
+void
queue_init_clone(Queue *t, Queue *s)
{
t->alloc = t->elements = sat_malloc2(s->count + 8, sizeof(Id));
}
void
-queue_init(Queue *q)
-{
- q->alloc = q->elements = 0;
- q->count = q->left = 0;
-}
-
-void
queue_init_buffer(Queue *q, Id *buf, int size)
{
q->alloc = 0;
void
queue_alloc_one(Queue *q)
{
- if (q->alloc && q->alloc != q->elements)
+ if (!q->alloc)
{
- memmove(q->alloc, q->elements, q->count * sizeof(Id));
- q->left += q->elements - q->alloc;
+ /* queue was created with queue_init_buf */
+ q->alloc = sat_malloc2(q->count + 8, sizeof(Id));
+ if (q->count)
+ memcpy(q->alloc, q->elements, q->count * sizeof(Id));
q->elements = q->alloc;
+ q->left = 8;
}
- else if (q->alloc)
+ else if (q->alloc != q->elements)
{
- q->elements = q->alloc = sat_realloc2(q->alloc, q->count + 8, sizeof(Id));
- q->left += 8;
+ int l = q->elements - q->alloc;
+ if (q->count)
+ memmove(q->alloc, q->elements, q->count * sizeof(Id));
+ q->elements -= l;
+ q->left += l;
}
else
{
- q->alloc = sat_malloc2(q->count + 8, sizeof(Id));
- if (q->count)
- memcpy(q->alloc, q->elements, q->count * sizeof(Id));
- q->elements = q->alloc;
- q->left += 8;
+ q->elements = q->alloc = sat_realloc2(q->alloc, q->count + 8, sizeof(Id));
+ q->left = 8;
}
}
+/* make room for an element in front of queue */
+void
+queue_alloc_one_head(Queue *q)
+{
+ int l;
+ if (!q->alloc || !q->left)
+ queue_alloc_one(q);
+ l = q->left > 8 ? 8 : q->left;
+ if (q->count);
+ memmove(q->elements + l, q->elements, q->count * sizeof(Id));
+ q->elements += l;
+ q->left -= l;
+}
+
void
queue_insert(Queue *q, int pos, Id id)
{
{
memmove(q->elements + pos + 2, q->elements + pos, (q->count - 2 - pos) * sizeof(Id));
q->elements[pos] = id1;
- q->elements[pos] = id2;
+ q->elements[pos + 1] = id2;
}
}
if (solv->installed && ps->repo == solv->installed)
{
if (!solv->updatemap.size)
- map_init(&solv->updatemap, pool->nsolvables);
+ map_grow(&solv->updatemap, pool->nsolvables);
MAPSET(&solv->updatemap, p);
if (!MAPTST(&solv->dupmap, p))
{
what = job->elements[i + 1];
select = how & SOLVER_SELECTMASK;
if (!noobsmap->size)
- map_init(noobsmap, pool->nsolvables);
+ map_grow(noobsmap, pool->nsolvables);
FOR_JOB_SELECT(p, pp, select, what)
MAPSET(noobsmap, p);
}
if (!solv->installed || s->repo != solv->installed)
continue;
if (!solv->updatemap.size)
- map_init(&solv->updatemap, pool->nsolvables);
+ map_grow(&solv->updatemap, pool->nsolvables);
MAPSET(&solv->updatemap, p);
}
break;
type = transaction_base_type(trans, p);
+ if (type == SOLVER_TRANSACTION_IGNORE)
+ return SOLVER_TRANSACTION_IGNORE; /* not part of the transaction */
+
if ((mode & SOLVER_TRANSACTION_RPM_ONLY) != 0)
{
/* application wants to know what to feed to rpm */
}
}
/* now sort all vendor/arch changes */
- if (classes->count)
+ if (classes->count > 4)
sat_sort(classes->elements, classes->count / 4, 4 * sizeof(Id), classify_cmp, trans);
/* finally add all classes. put erases last */
i = SOLVER_TRANSACTION_ERASE;
continue;
}
}
- if (pkgs->count)
+ if (pkgs->count > 1)
sat_sort(pkgs->elements, pkgs->count, sizeof(Id), classify_cmp_pkgs, trans);
}
if (p <= 0 || p == SYSTEMSOLVABLE)
continue;
s = pool->solvables + p;
- if (s->repo == installed)
+ if (!s->repo || s->repo == installed)
continue;
noobs = trans->noobsmap.size && MAPTST(&trans->noobsmap, p);
FOR_PROVIDES(p2, pp2, s->name)