nasm/rdoff/collectn.c
Yuri Zaporogets e0c059ab4e outrdf2.c now uses the same definitions of RDOFF2 format that RDOFF utils.
Export/import/common label size is increased from 33 to 64. Fixed the bug
that caused wrong behavior of rdfgetheaderrec() if label length was 32.
Changed error codes from numeric values to symbolic constants.
Moved some routines from rdfdump.c to rdoff.c. They will be utilized also
by rdfdisasm, which is being developed.
2004-09-15 06:54:34 +00:00

44 lines
701 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;
}