setDataBase method Null safety

void setDataBase(
  1. List<DataBaseElement> dataBase,
  2. {SearchAccelerationType acceleration = SearchAccelerationType.SEARCH_ACCELERATION_1}
)

Implementation

void setDataBase(List<DataBaseElement> dataBase, {SearchAccelerationType acceleration = SearchAccelerationType.SEARCH_ACCELERATION_1}) {
  final set_db = _dll_handle.lookupFunction<_VWsetDataBase, _VWsetDataBase_dart>(_c_namespace + 'VideoWorker_setDatabase');

  final data_base_size = dataBase.length;
  Pointer<Uint64> element_ids_v = malloc.allocate(data_base_size * sizeOf<Uint64>());
  Pointer<Uint64> person_ids_v = malloc.allocate(data_base_size * sizeOf<Uint64>());
  Pointer<Float> thresholds_v = malloc.allocate(data_base_size * sizeOf<Float>());
  Pointer<Pointer<Void>> templates_v = malloc.allocate(data_base_size * sizeOf<Pointer<Pointer<Void>>>());

  for (var i = 0; i < data_base_size; i++) {
    element_ids_v[i] = dataBase[i].element_id;
    person_ids_v[i] = dataBase[i].person_id;
    thresholds_v[i] = dataBase[i].distance_threshold;
    templates_v[i] = dataBase[i].face_template._impl;
  }

  Pointer<Pointer<Void>> exception = _getException();
  set_db(_impl, acceleration.index, data_base_size, element_ids_v, person_ids_v, templates_v, thresholds_v, exception);
  checkException(exception, _dll_handle);

  malloc.free(element_ids_v);
  malloc.free(person_ids_v);
  malloc.free(thresholds_v);
  malloc.free(templates_v);
}