minor changes
This commit is contained in:
parent
c61ee66f4c
commit
bc8a1a4001
1 changed files with 10 additions and 1 deletions
11
mem/mem.go
11
mem/mem.go
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Kilobyte uintptr = 1 << (10 * (iota + 1))
|
||||
Kilobyte = 1 << (10 * (iota + 1))
|
||||
Megabyte
|
||||
Gigabyte
|
||||
Terabyte
|
||||
|
|
@ -110,3 +110,12 @@ func Aligned(address uintptr, alignment uintptr) bool {
|
|||
}
|
||||
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)]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue