alloc<T extends NativeType> method

SodiumPointer<T> alloc<T extends NativeType>(
  1. int count, {
  2. bool zeroMemory = false,
  3. MemoryProtection memoryProtection = .readWrite,
})

Allocates a fresh, tracked output buffer of count elements.

The SodiumPointer is returned so callers can keep using ..fill(...), .viewAt(...), .ptr and .asListView() directly. If zeroMemory is set, the buffer is zeroed instead of filled with the 0xdb guard byte. Defaults to MemoryProtection.readWrite. Wraps SodiumPointer.alloc.

Implementation

SodiumPointer<T> alloc<T extends NativeType>(
  int count, {
  bool zeroMemory = false,
  MemoryProtection memoryProtection = .readWrite,
}) => _track(
  SodiumPointer<T>.alloc(
    _sodium,
    count: count,
    zeroMemory: zeroMemory,
    memoryProtection: memoryProtection,
  ),
);