allocateMalloc<T extends NativeType> method

Pointer<T> allocateMalloc<T extends NativeType>(
  1. int size
)

Allocate memory using malloc and track it

Implementation

Pointer<T> allocateMalloc<T extends NativeType>(int size) {
  if (_disposed) {
    throw OracleMemoryException('MemoryManager has been disposed');
  }

  try {
    final pointer = malloc.allocate<T>(size);
    _allocatedPointers.add(pointer);
    return pointer;
  } catch (e) {
    throw OracleMemoryException(
      'Failed to allocate memory for type $T with size $size: $e',
    );
  }
}