Buffer.resize

From GiderosMobile
Revision as of 08:48, 6 February 2025 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2025.1<br/> '''Class:''' buffer_luau<br/> === Description === Resizes the buffer and creates a new one. <syntaxhighlight lang="lu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2025.1
Class: buffer_luau

Description

Resizes the buffer and creates a new one.

(buffer) = buffer.resize(b,newSize,offset)

Parameters

b: (buffer) the buffer
newSize: (number) the new buffer size
offset: (number) offset from the beginning of the buffer memory, starting from 0 optional

Return values

Returns (buffer) a new buffer with the new size

Examples

local b = buffer.create(16)
b = buffer.resize(b, 48, 16)
print(buffer.len(b))

local mystr = "Hello Gideros!"
local b2 = buffer.fromstring(mystr)
b2 = buffer.resize(b2, 48, 0)
print(buffer.tostring(b2))