Auxiliary buffer uses external strings

The buffer system from the auxiliary library reuses its buffer
as external memory when closing long strings.
This commit is contained in:
Roberto Ierusalimschy
2023-11-13 13:12:33 -03:00
parent eabf425c76
commit 6d042a178f
3 changed files with 40 additions and 27 deletions

View File

@@ -728,14 +728,8 @@ if rawget(_G, "T") then
-- first buffer was released by 'toclose'
assert(T.totalmem() - m <= extra)
-- error in creation of final string
T.totalmem(m + 2 * lim + extra)
assert(not pcall(table.concat, a))
-- second buffer was released by 'toclose'
assert(T.totalmem() - m <= extra)
-- userdata, buffer, buffer, final string
T.totalmem(m + 4*lim + extra)
-- userdata, buffer, final string
T.totalmem(m + 2*lim + extra)
assert(#table.concat(a) == 2*lim)
T.totalmem(0) -- remove memory limit