RTempStringAlloc class final

A specialised slot-based allocator for C strings (Pointer\<Char>).

Maintains two separate pools:

  • Anonymous slots – a ring buffer of slotCount slots, cycled through via Value without a key. Useful for transient strings within a single frame.
  • Keyed slots – named slots allocated on demand via ValueAt and Array, persisting until explicitly freed or _dispose is called.

String memory is managed with malloc and is grown in-place when the encoded UTF-8 length of a new string exceeds the current slot capacity, avoiding unnecessary reallocations for strings of similar length.

Inheritance

Constructors

RTempStringAlloc(RaylibTemp temp, String name, {required int slotCount, required Pointer<Pointer<Char>> allocatorFunc([int count]), required String printerFunc(Pointer<Pointer<Char>> ptr)})

Properties

allocatorFunc Pointer<Pointer<Char>> Function([int count])
Low-level allocation function. Called with an element count and returns a freshly allocated Pointer<T>.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable name for this allocator, used in debug/log messages.
finalinherited
printerFunc String Function(Pointer<Pointer<Char>> ptr)
Debug printer: converts a Pointer<T> to a human-readable string.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
slotCount int
Number of anonymous (ring-buffer) string slots pre-reserved on construction.
final

Methods

Array(List<String> array, {String? key}) Pointer<Pointer<Char>>
Writes each string in array into keyed sub-slots and returns a tracked Pointer<Pointer<Char>> of length array.length.
At(String key, [int count = 1]) Pointer<Pointer<Char>>
Returns the Pointer<T> stored in key, allocating (or reallocating) if necessary.
inherited
Fill(int count, Pointer<Char> init(int), {String? key}) Pointer<Pointer<Char>>
Fills a tracked Pointer<Pointer<Char>> of count elements by calling init for each index.
Free(String key) → void
Frees the native memory owned by slot key and removes it from the table.
override
Has(String key) bool
Returns true if a slot with the given key exists.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
Raw([int count = 1]) Pointer<Pointer<Char>>
Allocates and returns an unslotted array of count Pointer<Char> pointers.
Ref1([String? o]) Pointer<Char>
Writes o into slot '1' and returns its pointer.
Ref2([String? o]) Pointer<Char>
Writes o into slot '2' and returns its pointer.
Ref3([String? o]) Pointer<Char>
Writes o into slot '3' and returns its pointer.
Ref4([String? o]) Pointer<Char>
Writes o into slot '4' and returns its pointer.
RefOrNull1(String? o) Pointer<Char>
Writes o into slot '1' and returns its pointer, or returns nullptr if o is null.
RefOrNull2(String? o) Pointer<Char>
Writes o into slot '2' and returns its pointer, or returns nullptr if o is null.
RefOrNull3(String? o) Pointer<Char>
Writes o into slot '3' and returns its pointer, or returns nullptr if o is null.
RefOrNull4(String? o) Pointer<Char>
Writes o into slot '4' and returns its pointer, or returns nullptr if o is null.
signature() String
Returns a string that identifies the concrete type of this allocator, including its type parameters (e.g. "RTempAlloc<Float>").
inherited
Slot(String key) Pointer<Pointer<Char>>?
Returns the pointer stored under key, or null if the slot does not exist. Does not allocate.
inherited
toString() String
A string representation of this object.
inherited
Unslot(String key) → void
Removes the slot entry for key from the table without freeing the underlying memory.
inherited
Value(String text, [String? key]) Pointer<Char>
Returns a Pointer<Char> for text using the next anonymous ring-buffer slot.
ValueAt(String key, [String? text]) Pointer<Char>
Returns the Pointer<Char> for the keyed slot key, optionally writing text into it.
ValueOrNull([String? text, String? key]) Pointer<Char>
Writes text into slot using Value and returns its pointer, or returns nullptr if text is null.

Operators

operator ==(Object other) bool
The equality operator.
inherited