12 clonequeue(Queue *t, Queue *s)
14 t->alloc = t->elements = malloc((s->count + 8) * sizeof(Id));
16 memcpy(t->alloc, s->elements, s->count * sizeof(Id));
24 q->alloc = q->elements = 0;
25 q->count = q->left = 0;
29 queueinit_buffer(Queue *q, Id *buf, int size)
42 q->alloc = q->elements = 0;
43 q->count = q->left = 0;
52 return *q->elements++;
56 queuepush(Queue *q, Id id)
60 if (q->alloc && q->alloc != q->elements)
62 memmove(q->alloc, q->elements, q->count * sizeof(Id));
63 q->left += q->elements - q->alloc;
64 q->elements = q->alloc;
68 q->elements = q->alloc = realloc(q->alloc, (q->count + 8) * sizeof(Id));
73 q->alloc = malloc((q->count + 8) * sizeof(Id));
75 memcpy(q->alloc, q->elements, q->count * sizeof(Id));
76 q->elements = q->alloc;
80 q->elements[q->count++] = id;
85 queuepushunique(Queue *q, Id id)
88 for (i = q->count; i > 0; )
89 if (q->elements[--i] == id)