PointerBuffer<T extends NativeType>.empty constructor Null safety

PointerBuffer<T extends NativeType>.empty(
  1. int elementSize
)

Implementation

PointerBuffer.empty(int elementSize) {
  _elementSizePointer = malloc.allocate(sizeOf<Int32>());
  _elementSizePointer.value = elementSize;

  _sizePointer = malloc.allocate(sizeOf<Int32>());
  _sizePointer.value = -1;

  _dataPointer = malloc.allocate(sizeOf<Pointer<Void>>());

  ptr = malloc.allocate(sizeOf<Int64>() * 3);
  Int64List ptrData = ptr.cast<Int64>().asTypedList(3);

  ptrData[0] = _elementSizePointer.address;
  ptrData[1] = _sizePointer.address;
  ptrData[2] = _dataPointer.address;
}