allocate method

  1. @override
void allocate(
  1. RaylibTemp<RaylibBase> temp,
  2. MemoryPointer<RType> p,
  3. String key, {
  4. int count = 1,
  5. bool raw = false,
})
override

Allocates any backing storage for a value at p, using temp and identified by key. count and raw are for codecs that allocate arrays or need unmanaged memory.

No-op by default: most codecs (scalar, enum, struct) don't own pointers, so there's nothing to allocate.

Implementation

@override
void allocate(RaylibTemp temp, MemoryPointer p, String key, {int count = 1, bool raw = false}) {
  if (!deref(p).isNull) return;
  final alloc = inner.allocator(temp);
  if (alloc == null) throw StateError('No allocator for ${inner.runtimeType}');
  final block = raw ? alloc.Raw(count) : alloc.At(key, count);
  p.writePtr(block);
  inner.allocate(temp, block, '${key}_inner', count: count, raw: raw);
}