1 /****************************************************************************
2 **
3 *A  is_space_exhausted.c        ANUPQ source                   Eamonn O'Brien
4 **
5 *Y  Copyright 1995-2001,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
6 *Y  Copyright 1995-2001,  School of Mathematical Sciences, ANU,     Australia
7 **
8 */
9 
10 #include "pq_defs.h"
11 #include "pcp_vars.h"
12 
13 /* beware - calls to this procedure are context sensitive since
14    it may call compact which moves strings; hence, calls should
15    be carefully placed with a suitable upper bound as argument;
16 
17    check if there is room available for required words;
18    if so, return FALSE, otherwise compact the workspace
19    and try again; if there is still no room, report this,
20    set pcp->overflow TRUE, and return TRUE */
21 
is_space_exhausted(int required,struct pcp_vars * pcp)22 Logical is_space_exhausted(int required, struct pcp_vars *pcp)
23 {
24    register int *y = y_address;
25 
26    int remain;
27 
28    if (pcp->lused + required - pcp->subgrp <= 0)
29       return FALSE;
30 
31    /* not enough room currently available, so we compact tables */
32    compact(pcp);
33    if (pcp->lused + required - pcp->subgrp <= 0)
34       return FALSE;
35    pcp->overflow = TRUE;
36    /* number of generators in last class */
37    remain = pcp->lastg - y[pcp->clend + pcp->cc - 1];
38    text(11, remain, 0, 0, 0);
39    return TRUE;
40 }
41