allocateMany method

List<Pointer<Point>> allocateMany(
  1. int count
)

Allocates multiple Point structs from the pool.

  • count: The number of points to allocate. Returns a list of pointers to the allocated points.

Implementation

List<Pointer<Point>> allocateMany(int count) {
  if (isDisposed) {
    throw StateError('Cannot allocate from disposed pool');
  }

  if (count > available) {
    throw ArgumentError(
        'Not enough space in pool ($available available, requested $count)');
  }

  final result = <Pointer<Point>>[];
  for (var i = 0; i < count; i++) {
    final ptr = allocate();
    if (ptr == null) break;
    result.add(ptr);
  }
  return result;
}