allocsize

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package allocsize computes the size of an allocation from lengths without wrapping.

Go's make checks a size it is given, but an `a + b` or `2*n + c` that wraps reaches it as a small or negative number: the first allocates too little and the caller then writes past it, the second panics late. These helpers return math.MaxInt for a sum or product that does not fit an int, so make panics ("len out of range"), as it does for any size larger than memory. Operands are lengths and capacities, never negative; a negative operand is treated like an overflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b int) int

Add returns a+b, or math.MaxInt when the sum does not fit an int.

func Mul

func Mul(a, b int) int

Mul returns a*b, or math.MaxInt when the product does not fit an int.

Types

This section is empty.

Jump to

Keyboard shortcuts

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