mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-12-03 08:41:02 +08:00
fe501957c0
Concentrate compiler dependencies to compiler.h; make sure compiler.h is included first in every .c file (since some prototypes may depend on the presence of feature request macros.) Actually use the conditional inclusion of various functions (totally broken in previous releases.)
46 lines
793 B
C
46 lines
793 B
C
/*
|
|
* collectn.c - implements variable length pointer arrays [collections].
|
|
*
|
|
* This file is public domain.
|
|
*/
|
|
|
|
#include "compiler.h"
|
|
#include <stdlib.h>
|
|
#include "collectn.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;
|
|
}
|