At method
Returns the Pointer<T> stored in key, allocating (or reallocating)
if necessary.
If the slot already exists and its current capacity is >= count, the
existing pointer is reused. If capacity is insufficient the old block is
freed and a new one of size count is allocated.
key – slot identifier (must not be null).
count – minimum element capacity required (default: 1).
Implementation
Pointer<T> At(String key, [int count = 1]) {
final existing = _Slots[key];
if (existing != null) {
final (ptr, currentCount) = existing;
if (count <= currentCount) {
// _temp.logInfo('[TEMP] Reusing slot for $T at $key with $count');
_Slots[key] = (ptr, count);
return ptr;
}
calloc.free(ptr);
}
// _temp.logInfo('[TEMP] Creating slot for $T at $key with $count');
final ptr = allocatorFunc(count);
_Slots[key] = (ptr, count);
return ptr;
}