lockedmem

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lockedmem holds secrets outside the Go heap: each Buf is an anonymous mapping of its own, so the collector never copies it, locked against swap where RLIMIT_MEMLOCK allows, excluded from core dumps, and zeroed before it is unmapped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buf

type Buf struct {
	// contains filtered or unexported fields
}

Buf is n bytes of locked memory. The zero Buf, and a destroyed one, hold nothing.

func Copy

func Copy(src []byte) (*Buf, error)

Copy is a new Buf holding a copy of src.

func New

func New(n int) (*Buf, error)

New maps n zeroed bytes of locked memory.

func (*Buf) Bytes

func (b *Buf) Bytes() []byte

Bytes is the buffer's memory, nil once destroyed. It must not be kept past Destroy.

func (*Buf) Destroy

func (b *Buf) Destroy()

Destroy zeroes and unmaps the buffer. It is safe to call more than once.

func (*Buf) Destroyed

func (b *Buf) Destroyed() bool

Destroyed reports whether the buffer holds nothing any more.

func (*Buf) Holds

func (b *Buf) Holds(p []byte) bool

Holds reports whether p lies wholly inside the buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL