saferio

Imports

Imports #

"io"
"unsafe"

Constants & Variables

chunk const #

chunk is an arbitrary limit on how much memory we are willing to allocate without concern.

const chunk = *ast.BinaryExpr

Functions

ReadData function #

ReadData reads n bytes from the input stream, but avoids allocating all n bytes if n is large. This avoids crashing the program by allocating all n bytes in cases where n is incorrect. The error is io.EOF only if no bytes were read. If an io.EOF happens after reading some but not all the bytes, ReadData returns io.ErrUnexpectedEOF.

func ReadData(r io.Reader, n uint64) ([]byte, error)

ReadDataAt function #

ReadDataAt reads n bytes from the input stream at off, but avoids allocating all n bytes if n is large. This avoids crashing the program by allocating all n bytes in cases where n is incorrect.

func ReadDataAt(r io.ReaderAt, n uint64, off int64) ([]byte, error)

SliceCap function #

SliceCap is like SliceCapWithSize but using generics.

func SliceCap(c uint64) int

SliceCapWithSize function #

SliceCapWithSize returns the capacity to use when allocating a slice. After the slice is allocated with the capacity, it should be built using append. This will avoid allocating too much memory if the capacity is large and incorrect. A negative result means that the value is always too big.

func SliceCapWithSize(size uint64, c uint64) int

Generated with Arrow