0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-11-08 23:27:15 -05:00
Files
nasm/rdoff/v1/collectn.c
H. Peter Anvin 41bf8002b2 NASM 0.98
2002-04-30 20:58:18 +00:00

41 lines
690 B
C

/* collectn.c Implements variable length pointer arrays [collections]
*
* This file is public domain.
*/
#include "collectn.h"
#include <stdlib.h>
void collection_init(Collection * c)
{
int i;
for (i = 0; i < 32; i++) c->p[i] = NULL;
c->next = NULL;
}
void ** colln(Collection * c, int index)
{
while (index >= 32) {
index -= 32;
if (c->next == NULL) {
c->next = malloc(sizeof(Collection));
collection_init(c->next);
}
c = c->next;
}
return &(c->p[index]);
}
void collection_reset(Collection *c)
{
int i;
if (c->next) {
collection_reset(c->next);
free(c->next);
}
c->next = NULL;
for (i = 0; i < 32; i++) c->p[i] = NULL;
}