Skip to content

Commit

Permalink
Re-use the remaining WorkSpace for each term through Generator
Browse files Browse the repository at this point in the history
Generator consumes WorkSpace, so here we run out very easily if we
don't reset the position that we use, each iteration.
  • Loading branch information
jodavies committed Jun 5, 2024
1 parent d5413c8 commit 603737d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sources/optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4453,15 +4453,19 @@ WORD generate_expression (WORD exprnr) {
// scan for the original expression (marked by *t<0) and give the
// terms to Generator
WORD *t = AO.OptimizeResult.code;
{
{
WORD old = AR.Cnumlhs; AR.Cnumlhs = 0;
// We can use the remaining part of the WorkSpace for every term that
// goes through Generator. We have WorkSpace problems here if we use
// the (modified) AT.WorkPointer every time in the loop.
WORD* currentWorkPointer = AT.WorkPointer;
while (*t!=0) {
bool is_expr = *t < 0;
t++;
while (*t!=0) {
if (is_expr) {
memcpy(AT.WorkPointer, t, *t*sizeof(WORD));
Generator(BHEAD AT.WorkPointer, C->numlhs);
memcpy(currentWorkPointer, t, *t*sizeof(WORD));
Generator(BHEAD currentWorkPointer, C->numlhs);
}
t+=*t;
}
Expand Down

0 comments on commit 603737d

Please sign in to comment.