writeToSlot method
Writes text into slot slot, reallocating if the current capacity is
insufficient for the UTF-8 encoded length.
Always null-terminates the written string.
Implementation
@override
WasmStringPointer writeToSlot(int slot, String text, [int? bufferSize]) {
final requiredBytes = Length(text, bufferSize);
reallocSlotIfRequired(slot, requiredBytes);
WasmMemory.stringToUTF8(text, stringSlots[slot].address, requiredBytes);
return WasmStringPointer(stringSlots[slot].address);
}