rdoff: add back rdfutils.h missing from previous checkin
[nasm.git] / rdoff / collectn.c
blobd77f54b5c4bc3dec39466f3a13cc3868b2c9ea66
1 /*
2 * collectn.c - implements variable length pointer arrays [collections].
4 * This file is public domain.
5 */
7 #include "rdfutils.h"
8 #include "collectn.h"
10 void collection_init(Collection * c)
12 int i;
14 for (i = 0; i < 32; i++)
15 c->p[i] = NULL;
16 c->next = NULL;
19 void **colln(Collection * c, int index)
21 while (index >= 32) {
22 index -= 32;
23 if (c->next == NULL) {
24 c->next = nasm_malloc(sizeof(Collection));
25 collection_init(c->next);
27 c = c->next;
29 return &(c->p[index]);
32 void collection_reset(Collection * c)
34 int i;
36 if (c->next) {
37 collection_reset(c->next);
38 nasm_free(c->next);
41 c->next = NULL;
42 for (i = 0; i < 32; i++)
43 c->p[i] = NULL;