home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: rmemfix.c - memory managemnt functions for fixed regions
- * Contents: initalloc, reclaim
- */
-
- /*
- * Prototype.
- */
-
- hidden novalue reclaim Params((int region));
-
- /*
- * initalloc - initialization routine to allocate memory regions
- */
-
- novalue initalloc(codesize)
- word codesize;
- {
- static char dummy[1]; /* dummy static region */
-
- /*
- * Allocate icode region
- */
- if ((code = (char *)AllocReg(codesize)) == NULL)
- error("insufficient memory for icode");
-
- /*
- * Set up allocated memory. The regions are:
-
- * Static memory region (not used)
- * Allocated string region
- * Allocate block region
- * Qualifier list
- */
-
- statend = statfree = statbase = dummy;
- if ((strfree = strbase = (char *)AllocReg(ssize)) == NULL)
- error("insufficient memory for string region");
- strend = strbase + ssize;
- if ((blkfree = blkbase = (char *)AllocReg(abrsize)) == NULL)
- error("insufficient memory for block region");
- blkend = blkbase + abrsize;
- if ((quallist = (dptr *)AllocReg(qualsize)) == NULL)
- error("insufficient memory qualifier list");
- equallist = (dptr *)((char *)quallist + qualsize);
- }
-
- /*
- * reclaim - reclaim space in the allocated memory regions. The marking
- * phase has already been completed.
- */
-
- static novalue reclaim(region)
- int region;
- {
- /*
- * Collect available co-expression blocks.
- */
- cofree();
-
- /*
- * Collect the string space leaving it where it is.
- */
- if (!qualfail)
- scollect((word)0);
-
- /*
- * Adjust the blocks in the block region in place.
- */
- adjust(blkbase,blkbase);
-
- /*
- * Compact the block region.
- */
- compact(blkbase);
- }
-