NativeStringAlloc 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 callsite.
- Keyed slots – named slots allocated on demand via ValueAt and
Array, persisting until explicitly freed or
_disposeis 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
-
- Object
- RaylibTempAllocatorBase<
RaylibTemp, Pointer< Char> , Pointer<Char> > - NativeAlloc<
Char> - NativeStringAlloc
- Mixed-in types
Constructors
-
NativeStringAlloc(RaylibTemp temp, String name, {required int slotCount, required Pointer<
Char> allocatorFunc([int count])})
Properties
-
allocatorFunc
→ Pointer<
Char> Function([int count]) -
Allocates
countelements and returns the raw source pointer.finalinherited - byteSize → int
-
Size in bytes of a single element this allocator manages.
finalinherited
-
freeFunc
→ void Function(Pointer<
Char> ptr) -
Frees the memory at
ptr.finalinherited -
freePPFunc
↔ void Function(Pointer<
Pointer< ptr)Char> > -
latefinaloverride-getter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
indexSetterFunc
↔ void Function(Pointer<
Pointer< ptrptr, int i, Pointer<Char> >Char> ptr) -
latefinaloverride-getter
-
isPointerNull
→ bool Function(Pointer<
Char> ptr) -
Returns
trueifptris null or zero.finalinherited - name → String
-
Debug name for this allocator, used in logging and diagnostics.
finalinherited
-
nullptrFactory
→ Pointer<
Char> Function() -
Returns a null/zero pointer of type
P.finalinherited -
pointerFactory
→ Pointer<
Char> Function(Pointer<Char> ptr) -
Wraps a source pointer
ptrinto the platform pointer typeP.finalinherited -
pointerToSource
→ Pointer<
Char> Function(Pointer<Char> ptr) -
Unwraps a platform pointer
ptrback to its source typeS.finalinherited -
printerFunc
→ String Function(Pointer<
Char> ptr) -
Returns a human-readable string representation of
ptr.finalinherited -
ptrAllocatorFunc
↔ Pointer<
Pointer< Function(int count)Char> > -
latefinaloverride-getter
- ptrByteSize → int
-
no setteroverride
- 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
-
slots
→ Map<
String, (Pointer< Char> , int)> -
Active allocation slots, keyed by slot name.
Each entry holds the pointer and its element count.
finalinherited
- stringAnonIndex ↔ int
-
getter/setter pairinherited
-
stringCapacities
↔ List<
int> -
getter/setter pairinherited
-
stringSlots
↔ List<
Pointer< Char> > -
getter/setter pairinherited
-
stringSlotsKeyed
→ Map<
String, int> -
finalinherited
-
stringSlotsPtrsKeyed
→ Map<
String, (Pointer< Pointer< , int)>Char> > -
finalinherited
- temp → RaylibTemp
-
finalinherited
Methods
-
Array(
List< String> array, {String? key}) → Pointer<Pointer< Char> > -
Writes each string in
arrayinto keyed sub-slots and returns a trackedPPof lengtharray.length.inherited -
At(
String key, [int count = 1]) → Pointer< Char> -
Returns the
Pstored inkey, allocating (or reallocating) if necessary.inherited -
AtPtr(
String key, [int count = 1]) → Pointer< Pointer< Char> > -
inherited
-
AtUnique(
String key, [int count = 1]) → Pointer< Char> -
Allocates (or reuses) a slot identified by a unique
keysuffix.inherited -
dispose(
) → void -
Frees all currently tracked slots and clears the slot table.
inherited
-
Fill(
int count, Pointer< Char> init(int), {String? key}) → Pointer<Pointer< Char> > -
Fills a tracked
PPofcountelements by calling init for each index.inherited -
Free(
String key) → void -
Frees the native memory owned by slot
keyand removes it from the table.inherited -
Has(
String key) → bool -
Returns
trueif a slot with the givenkeyexists.inherited -
Length(
String text, [int? bufferSize]) → int -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
Raw(
[int count = 1]) → Pointer< Char> -
Allocates
countraw elements and returns the wrapped pointer.inherited -
reallocSlotIfRequired(
int slot, int length) → void -
inherited
-
Ref1(
[String? o, int? bufferSize]) → Pointer< Char> -
Writes
ointo slot'1'and returns its pointer.inherited -
Ref2(
[String? o, int? bufferSize]) → Pointer< Char> -
Writes
ointo slot'2'and returns its pointer.inherited -
Ref3(
[String? o, int? bufferSize]) → Pointer< Char> -
Writes
ointo slot'3'and returns its pointer.inherited -
Ref4(
[String? o, int? bufferSize]) → Pointer< Char> -
Writes
ointo slot'4'and returns its pointer.inherited -
RefOrNull1(
String? o) → Pointer< Char> -
Writes
ointo slot'1'and returns its pointer, or returns nullptr ifoisnull.inherited -
RefOrNull2(
String? o) → Pointer< Char> -
Writes
ointo slot'2'and returns its pointer, or returns nullptr ifoisnull.inherited -
RefOrNull3(
String? o) → Pointer< Char> -
Writes
ointo slot'3'and returns its pointer, or returns nullptr ifoisnull.inherited -
RefOrNull4(
String? o) → Pointer< Char> -
Writes
ointo slot'4'and returns its pointer, or returns nullptr ifoisnull.inherited -
reset(
) → void -
Resets all slot bookkeeping structures to their initial state.
inherited
-
signature(
) → String -
Returns a string that identifies the concrete type of this allocator,
including its type parameters.
inherited
-
Size(
[int count = 1]) → int -
Returns the total byte size for
countelements.inherited -
Slot(
String key) → Pointer< Char> ? -
Returns the pointer stored under
key, ornullif the slot does not exist. Does not allocate.inherited -
slotKey(
[String? key]) → String -
Returns the canonical slot key for
key, falling back to'struct'whenkeyisnull.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
uniqueSlotKey(
String key) → String -
Returns a slot key guaranteed to be unique within this temp context,
by prefixing
keywith the next available ID.inherited -
Unslot(
String key) → void -
Removes the slot entry for
keyfrom the table without freeing the underlying memory.inherited -
Value(
String text, [String? key]) → Pointer< Char> -
Returns a
Pfortextusing the next anonymous ring-buffer slot.inherited -
ValueAt(
String key, [String? text, int? bufferSize]) → Pointer< Char> -
Returns the
Pfor the keyed slotkey, optionally writingtextinto it.inherited -
ValueOrNull(
[String? text, String? key]) → Pointer< Char> -
Writes
textinto slot usingValueand returns its pointer, or returns nullptr iftextisnull.inherited -
writeToSlot(
int slot, String text, [int? bufferSize]) → Pointer< Char> -
Writes
textinto slotslot, reallocating if the current capacity is insufficient for the UTF-8 encoded length.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited