ludic/changes/string-temporaries.md
Orkuncakilkaya 9660587e10 compiler: free a string an expression made once it has been used
The left half of a + chain, a template's pieces and holes, a number's text and a side made only to be
compared are marked fresh and freed after the +, ==, != or print that reads them. lp_int_str and
lp_long_str move their digits to the start of the buffer, so the pointer they return is the one
malloc gave. Reseeded. examples/lang/string_temps.ludic: kept intermediates stay good, and 20,000
rounds grow the heap 0 bytes (2.9 MB before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 12:06:45 +03:00

666 B

bump: patch type: fix A string made in the middle of an expression is freed once it has been used. a + "/" + b made a + "/", copied it and kept it for ever; a template made one such piece per hole, plus each number's text; and a side of == built only to be compared stayed too. The compiler now frees each of those as soon as the next +, the comparison or print has read it, and string(n) hands back the start of what it allocated so its text can be freed at all. A string held anywhere - a variable, an argument, a function's result - is left alone. A loop of 20,000 template builds grew 2.9 MB and now grows 0 (examples/lang/string_temps.ludic).