Recently I made a small assembly routine, for a function (FN) to quickly remove trailing spaces from strings.
Effectively if there are trailing spaces the value of !(^string$+4) is lowered.
Apparently, butchering the length of a local string variable that way messes up the mechanism to return heap space after leaving the function as eventually the "No room" message is given, both in BB4W as in BBCSDL.
I can illustrate this with the following:
Code: Select all
N%=50000
DIM E% -1
PRINT 0, ~E%
FOR I%=1 TO N%
J%+=LENFNTrim1("ABC01234567890123456789")
NEXT
DIM E% -1
PRINT J%, ~E%
FOR I%=1 TO N%
K%+=LENFNTrim2("ABC01234567890123456789")
NEXT
DIM E% -1
PRINT K%, ~E%
END
DEF FNTrim1(s$)=LEFT$(s$, 3)
DEF FNTrim2(s$)
!(^s$ + 4) = 3
=s$
Can there anything be done to return heap space after lowering the length of a local string variable like I pictured?
Thanks,
Mike