NASM 0.91
[nasm/avx512.git] / rdoff / collectn.c
blobc265c95f17e0c94b8cb5c7c627214e080b0db379
1 /* collectn.c Implements variable length pointer arrays [collections]
3 * This file is public domain.
4 */
6 #include "collectn.h"
7 #include <stdlib.h>
9 void collection_init(Collection * c)
11 int i;
13 for (i = 0; i < 32; i++) c->p[i] = NULL;
14 c->next = NULL;
17 void ** colln(Collection * c, int index)
19 while (index >= 32) {
20 index -= 32;
21 if (c->next == NULL) {
22 c->next = malloc(sizeof(Collection));
23 collection_init(c->next);
25 c = c->next;
27 return &(c->p[index]);
30 void collection_reset(Collection *c)
32 int i;
33 if (c->next) {
34 collection_reset(c->next);
35 free(c->next);
38 c->next = NULL;
39 for (i = 0; i < 32; i++) c->p[i] = NULL;