Remove free queue and use st_alloc/free from alloc module

This commit is contained in:
bruce 1987-07-13 10:07:33 +00:00
parent c8aaa59e1c
commit dc8d6ce37b
3 changed files with 8 additions and 28 deletions

View file

@ -63,6 +63,7 @@ main(argc,argv)
default: default:
FLUSHDFA(); FLUSHDFA();
EM_mkcalls(p); EM_mkcalls(p);
OO_free(p);
break; break;
case EM_EOF: case EM_EOF:
goto got_eof; goto got_eof;

View file

@ -6,14 +6,12 @@ static char rcsid2[] = "$Header$";
extern int OO_maxpattern; /* Initialized from patterns in dfa.c */ extern int OO_maxpattern; /* Initialized from patterns in dfa.c */
#define MAXBACKUP 50 #define MAXBACKUP 50
#define MAXOUTPUT 200 #define MAXOUTPUT 200
#define MAXFREEI 200
#define MAXSTRING 1000 #define MAXSTRING 1000
extern char em_mnem[][4]; extern char em_mnem[][4];
extern char em_pseu[][4]; extern char em_pseu[][4];
p_instr *OO_freeiqueue; p_instr OO_freeq;
p_instr *OO_nxtifree;
p_instr *OO_patternqueue; p_instr *OO_patternqueue;
p_instr *OO_nxtpatt; p_instr *OO_nxtpatt;
p_instr *OO_bkupqueue; p_instr *OO_bkupqueue;
@ -25,7 +23,6 @@ static p_instr *lastbackup;
static p_instr *outputqueue; static p_instr *outputqueue;
static p_instr *nextoutput; static p_instr *nextoutput;
static p_instr *lastoutput; static p_instr *lastoutput;
static p_instr *lastifree;
static char *strqueue; static char *strqueue;
static char *nextstr; static char *nextstr;
static char *laststr; static char *laststr;
@ -88,9 +85,6 @@ allocmem()
(p_instr *)Malloc(MAXOUTPUT*sizeof(p_instr)); (p_instr *)Malloc(MAXOUTPUT*sizeof(p_instr));
lastoutput = outputqueue + MAXOUTPUT - 1; lastoutput = outputqueue + MAXOUTPUT - 1;
OO_noutput = 0; OO_noutput = 0;
OO_nxtifree = OO_freeiqueue =
(p_instr *)Malloc(MAXFREEI*sizeof(p_instr));
lastifree = OO_freeiqueue + MAXFREEI - 1;
nextstr = strqueue = nextstr = strqueue =
(char *)Malloc(MAXSTRING*sizeof(char)); (char *)Malloc(MAXSTRING*sizeof(char));
laststr = strqueue + MAXSTRING - 1; laststr = strqueue + MAXSTRING - 1;
@ -101,27 +95,13 @@ allocmem()
OO_OTHER->em_argtype = 0; OO_OTHER->em_argtype = 0;
} }
OO_free(p)
p_instr p;
{
if(OO_nxtifree > lastifree) {
#ifdef DEBUG
fprintf(stderr,"Warning: Overflow of free intr. queue.\n");
fprintf(stderr,"Ignored free of ");
prtinst(p);
fprintf(stderr,"\n");
printstate("Freea overflow");
#endif
return;
}
*OO_nxtifree++ = p;
}
OO_nfree(n) OO_nfree(n)
register int n; register int n;
{ {
register p_instr *p = OO_nxtpatt = OO_patternqueue;
while(n--) { while(n--) {
OO_free(*--OO_nxtpatt); OO_free(*p); /* OO_free is macro so don't use *p++ */
p++;
} }
OO_state = 0; OO_state = 0;
} }

View file

@ -21,11 +21,10 @@ typedef struct e_instr *p_instr;
*OO_nxtpatt++ = OO_OTHER; OO_dfa(OTHER);\ *OO_nxtpatt++ = OO_OTHER; OO_dfa(OTHER);\
} else if(OO_noutput) OO_flush(); } else if(OO_noutput) OO_flush();
#define GETINSTR() (OO_nxtifree>OO_freeiqueue)?*(--OO_nxtifree):\ #define GETINSTR() ((p_instr)st_alloc((char **)&OO_freeq,sizeof(struct e_instr),20))
((p_instr)Malloc(sizeof(struct e_instr))) #define OO_free(p) st_free((p),&OO_freeq,sizeof(struct e_instr))
extern p_instr *OO_freeiqueue; extern p_instr OO_freeq;
extern p_instr *OO_nxtifree;
extern p_instr *OO_patternqueue; extern p_instr *OO_patternqueue;
extern p_instr *OO_nxtpatt; extern p_instr *OO_nxtpatt;
extern p_instr *OO_bkupqueue; extern p_instr *OO_bkupqueue;