aboutsummaryrefslogtreecommitdiff
path: root/backendC/CleanCompilerSources
diff options
context:
space:
mode:
authorjohnvg2012-06-19 11:44:16 +0000
committerjohnvg2012-06-19 11:44:16 +0000
commit318006f80cf95deb84b8936715f6994ee1738474 (patch)
treee83e1d9b98e38fc03c1dc1225f6c288155540f78 /backendC/CleanCompilerSources
parentincrease available memory (1000 instead of 200 blocks of 16k) for the strictn... (diff)
reallocate (enlarge) gCurrentNodeIds array if necessary
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2105 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'backendC/CleanCompilerSources')
-rw-r--r--backendC/CleanCompilerSources/backend.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/backendC/CleanCompilerSources/backend.c b/backendC/CleanCompilerSources/backend.c
index b01274a..aa81c81 100644
--- a/backendC/CleanCompilerSources/backend.c
+++ b/backendC/CleanCompilerSources/backend.c
@@ -150,9 +150,6 @@ STRUCT (be_state, BEState)
static BEStateS gBEState = {False /* ... */};
-/* +++ dynamic allocation */
-# define kMaxNumberOfNodeIds 1000
-
STRUCT (be_locally_generated_function_info, BELocallyGeneratedFunction)
{
char *lgf_name;
@@ -164,7 +161,8 @@ static BELocallyGeneratedFunctionS gLocallyGeneratedFunctions[] = {{"_dictionary
# define kDictionaryUpdate 1
// +++ put in gBEState
-static NodeIdP gCurrentNodeIds [kMaxNumberOfNodeIds];
+static NodeIdP (*gCurrentNodeIds)=NULL;
+static int n_gCurrentNodeIds = 0;
static SymbolP gBasicSymbols [Nr_Of_Predef_FunsOrConses];
static SymbolP gTupleSelectSymbols [MaxNodeArity];
@@ -2154,13 +2152,34 @@ BEArgs (BENodeP node, BEArgP nextArgs)
return (arg);
} /* BEArgs */
+static void increase_number_of_node_ids (int sequenceNumber)
+{
+ if (n_gCurrentNodeIds==0){
+ gCurrentNodeIds = malloc (1000*sizeof (NodeId *));
+ if (gCurrentNodeIds!=NULL)
+ n_gCurrentNodeIds = 1000;
+ }
+
+ while (sequenceNumber>=n_gCurrentNodeIds){
+ static NodeIdP (*new_gCurrentNodeIds);
+
+ new_gCurrentNodeIds = realloc (gCurrentNodeIds,(n_gCurrentNodeIds+(n_gCurrentNodeIds>>1)) * sizeof (NodeId *));
+ if (new_gCurrentNodeIds==NULL)
+ return;
+
+ gCurrentNodeIds = new_gCurrentNodeIds;
+ n_gCurrentNodeIds += (n_gCurrentNodeIds>>1);
+ }
+}
+
void
BEDeclareNodeId (int sequenceNumber, int lhsOrRhs, CleanString name)
{
IdentP newIdent;
NodeIdP newNodeId;
- Assert (sequenceNumber < kMaxNumberOfNodeIds);
+ if (sequenceNumber>=n_gCurrentNodeIds)
+ increase_number_of_node_ids (sequenceNumber);
/* +++ ifdef DEBUG */
if (sequenceNumber>=number_of_node_ids){
@@ -2200,8 +2219,6 @@ BENodeId (int sequenceNumber)
{
NodeIdP nodeId;
- Assert ((unsigned)sequenceNumber < (unsigned)kMaxNumberOfNodeIds);
-
/* +++ ifdef DEBUG */
if (sequenceNumber>=number_of_node_ids){
int i;
@@ -2258,8 +2275,6 @@ BENodeDef (int sequenceNumber, BENodeP node)
NodeIdP nodeId;
NodeDefP nodeDef;
- Assert ((unsigned)sequenceNumber < (unsigned)kMaxNumberOfNodeIds);
-
/* +++ ifdef DEBUG */
if (sequenceNumber>=number_of_node_ids){
int i;
@@ -3854,14 +3869,8 @@ BECloseFiles (void)
std_error_file_p = stderr;
#else
fclose (StdError);
-#endif
- StdErrorReopened = False;
- }
- if (StdOutReopened){
-#ifdef _SUN_
- fclose (std_out_file_p);
- std_out_file_p = stdout;
-#else
+ StdErrorReopened = False;
+ if (StdOutReopened)
fclose (StdOut);
#endif
StdOutReopened = False;