make: Lift up openwcom.mak for build on FreeDOS
[nasm.git] / rdoff / collectn.c
blob317c5286b4c94bbacf41c44903d4329ac80598e0
1 /*
2 * collectn.c - implements variable length pointer arrays [collections].
4 * This file is public domain.
5 */
7 #include "compiler.h"
8 #include <stdlib.h>
9 #include "collectn.h"
11 void collection_init(Collection * c)
13 int i;
15 for (i = 0; i < 32; i++)
16 c->p[i] = NULL;
17 c->next = NULL;
20 void **colln(Collection * c, int index)
22 while (index >= 32) {
23 index -= 32;
24 if (c->next == NULL) {
25 c->next = malloc(sizeof(Collection));
26 collection_init(c->next);
28 c = c->next;
30 return &(c->p[index]);
33 void collection_reset(Collection * c)
35 int i;
37 if (c->next) {
38 collection_reset(c->next);
39 free(c->next);
42 c->next = NULL;
43 for (i = 0; i < 32; i++)
44 c->p[i] = NULL;