toSodiumPointer method

SodiumPointer<Char> toSodiumPointer(
  1. LibSodiumFFI sodium, {
  2. int? memoryWidth,
  3. bool zeroTerminated = false,
  4. MemoryProtection memoryProtection = MemoryProtection.readWrite,
})

Converts the string to a SodiumPointer&lt;Int8&gt;

This simply combines StringX.toCharArray with Int8SodiumList.toSodiumPointer.

Implementation

SodiumPointer<Char> toSodiumPointer(
  LibSodiumFFI sodium, {
  int? memoryWidth,
  bool zeroTerminated = false,
  MemoryProtection memoryProtection = MemoryProtection.readWrite,
}) {
  late final SodiumPointer<Char> ptr;
  toCharArray(
    memoryWidth: memoryWidth,
    zeroTerminated: zeroTerminated,
    allocator: (length) =>
        (ptr = SodiumPointer.alloc(sodium, count: length)).asListView(),
  );
  ptr.memoryProtection = memoryProtection;
  return ptr;
}