Add a function gc_start to reset the garbage collector
This commit is contained in:
parent
07f442c3d9
commit
b3695cb900
|
|
@ -101,6 +101,7 @@ Some tokens should not be deleted here, they need another copying.
|
||||||
static char *MIFgettok_gc(char **line);
|
static char *MIFgettok_gc(char **line);
|
||||||
static char *MIFget_token_gc(char **s, Mif_Token_Type_t *type);
|
static char *MIFget_token_gc(char **s, Mif_Token_Type_t *type);
|
||||||
static char *copy_gc(char *in);
|
static char *copy_gc(char *in);
|
||||||
|
static void gc_start(void);
|
||||||
static void gc_end(void);
|
static void gc_end(void);
|
||||||
|
|
||||||
#define MIFgettok MIFgettok_gc
|
#define MIFgettok MIFgettok_gc
|
||||||
|
|
@ -202,6 +203,8 @@ MIF_INP2A (
|
||||||
/* get the line text from the card struct */
|
/* get the line text from the card struct */
|
||||||
line = current->line;
|
line = current->line;
|
||||||
|
|
||||||
|
/* reset the garbage collector */
|
||||||
|
gc_start();
|
||||||
|
|
||||||
/* get the name of the instance and add it to the symbol table */
|
/* get the name of the instance and add it to the symbol table */
|
||||||
name = copy(MIFgettok(&line));
|
name = copy(MIFgettok(&line));
|
||||||
|
|
@ -400,6 +403,7 @@ MIF_INP2A (
|
||||||
if(next_token_type != MIF_LARRAY_TOK) {
|
if(next_token_type != MIF_LARRAY_TOK) {
|
||||||
LITERR("Missing [, an array connection was expected");
|
LITERR("Missing [, an array connection was expected");
|
||||||
printf("Missing [, an array connection was expected. Returning . . .");
|
printf("Missing [, an array connection was expected. Returning . . .");
|
||||||
|
gc_end();
|
||||||
return;
|
return;
|
||||||
} else /* eat the [ */
|
} else /* eat the [ */
|
||||||
next_token = MIFget_token(&line,&next_token_type);
|
next_token = MIFget_token(&line,&next_token_type);
|
||||||
|
|
@ -1030,13 +1034,22 @@ char *MIFget_token_gc(char **s, Mif_Token_Type_t *type)
|
||||||
return newtok;
|
return newtok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void gc_start(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < BSIZE_SP; i++)
|
||||||
|
alltokens[i] = NULL;
|
||||||
|
curtoknr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void gc_end(void)
|
void gc_end(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i = 0; i < BSIZE_SP; i++) {
|
for (i = 0; i < BSIZE_SP; i++) {
|
||||||
/* We have multiple entries with the same address */
|
/* We have multiple entries with the same address */
|
||||||
for (j = i + 1; j < BSIZE_SP; j++)
|
for (j = i + 1; j < curtoknr; j++)
|
||||||
if (alltokens[i] == alltokens[j])
|
if (alltokens[i] == alltokens[j])
|
||||||
alltokens[j] = NULL;
|
alltokens[j] = NULL;
|
||||||
tfree(alltokens[i]);
|
tfree(alltokens[i]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue