zeroize
Signature
zeroize(value: string): Result<void, MemoryError>Signature
zeroize(value: u8[]): Result<void, MemoryError>zeroize(value) consumes a local string or u8[]. It overwrites the allocation with zeroes through volatile writes, places a compiler fence after the writes, and releases the allocation. The binding cannot be used afterward.
Dynamic strings must have exactly one live reference. String literals, borrows, and shared strings are rejected with MemoryError because erasing them would either write read-only storage or mutate data still visible through another value.
tyrus
import { MemoryError, zeroize } from "tyrus:memory";
function eraseToken(): void throws MemoryError {
let token: string = readToken();
zeroize(token);
}
function main(): void {
try {
eraseToken();
} catch (error: MemoryError) {
print(error.code); // ERR_MEMORY_NOT_OWNED or ERR_MEMORY_SHARED_VALUE
}
}