readRawSpectrumInfoArr method

List<RawSpectrumData> readRawSpectrumInfoArr()

Implementation

List<RawSpectrumData> readRawSpectrumInfoArr() {
  final size = _readSpectrumArrSize();

  final nativeRawSpectrumDataPtr = calloc.allocate<NativeRawSpectrumData>(sizeOf<NativeRawSpectrumData>() * size);
  final sizePtr = calloc<Uint32>();
  sizePtr.value = size;

  try {
    bindings.SpectrumMathReadRawSpectrumInfoArr(_pointer, nativeRawSpectrumDataPtr, sizePtr);
    return List.generate(size, (index) {
      var native = nativeRawSpectrumDataPtr[index];
      var managed = native.toManaged();

      native.dispose();

      return managed;
    });
  } finally {
    calloc.free(nativeRawSpectrumDataPtr);
    calloc.free(sizePtr);
  }
}