minor changes

This commit is contained in:
Judah Caruso 2026-01-31 00:59:14 -07:00
parent c61ee66f4c
commit bc8a1a4001

View file

@ -5,7 +5,7 @@ import (
) )
const ( const (
Kilobyte uintptr = 1 << (10 * (iota + 1)) Kilobyte = 1 << (10 * (iota + 1))
Megabyte Megabyte
Gigabyte Gigabyte
Terabyte Terabyte
@ -110,3 +110,12 @@ func Aligned(address uintptr, alignment uintptr) bool {
} }
return address&(alignment-1) == 0 return address&(alignment-1) == 0
} }
// ExtendSlice returns a copy of the given slice, increasing its length, but leaving the capacity intact.
func ExtendSlice[T any](slice []T, amount uintptr) []T {
if amount+uintptr(len(slice)) > uintptr(cap(slice)) {
panic("extendslice: cannot extend slice past its capacity")
}
return slice[: uintptr(len(slice))+amount : cap(slice)]
}