allocateUint8Pointer function

Pointer<Uint8> allocateUint8Pointer(
  1. List<int> list
)

Implementation

Pointer<Uint8> allocateUint8Pointer(List<int> list) {
  // 分配足够的内存
  final memory = malloc<Uint8>(list.length);
  if (list is Uint8List) {
    memory.asTypedList(list.length).setAll(0, list);

    return memory;
  }
  Uint8List uint8List = Uint8List.fromList(list);
  // 将 list 元素复制到分配的内存中
  memory.asTypedList(uint8List.length).setAll(0, uint8List);

  return memory;
}