setSize method Null safety

void setSize(
  1. int newLength
)

Implementation

void setSize(int newLength) {
  if(length != -1)
    malloc.free(_dataPointer.value);

  _sizePointer.value = newLength;
  _dataPointer.value = malloc.allocate(elementSize * newLength);

  if(_dataPointer.value.address == nullptr.address)
    throw Exception("RawSample.setSize: Failed to allocate a ${elementSize * newLength} bytes");
}