From 71a0beb68d4c61ce7c7a9c7f8aa2189ccfe619b2 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Wed, 30 Aug 2023 04:23:55 +0000 Subject: all: rewrite internal/saferio.SliceCap using generics and add func SliceCapWithSize Change-Id: I265173bf2722796c4be545c968efef3a1a6f7a7d GitHub-Last-Rev: 04d95cdd615f906167545f246f707e1440c39374 GitHub-Pull-Request: golang/go#62365 Reviewed-on: https://go-review.googlesource.com/c/go/+/524257 LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Russ Cox Reviewed-by: Ian Lance Taylor --- src/debug/macho/fat.go | 2 +- src/debug/macho/file.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/debug/macho') diff --git a/src/debug/macho/fat.go b/src/debug/macho/fat.go index 679cefb313..cc2134626f 100644 --- a/src/debug/macho/fat.go +++ b/src/debug/macho/fat.go @@ -86,7 +86,7 @@ func NewFatFile(r io.ReaderAt) (*FatFile, error) { // Following the fat_header comes narch fat_arch structs that index // Mach-O images further in the file. - c := saferio.SliceCap((*FatArch)(nil), uint64(narch)) + c := saferio.SliceCap[FatArch](uint64(narch)) if c < 0 { return nil, &FormatError{offset, "too many images", nil} } diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index 7cba3398fb..74a4da4da6 100644 --- a/src/debug/macho/file.go +++ b/src/debug/macho/file.go @@ -263,7 +263,7 @@ func NewFile(r io.ReaderAt) (*File, error) { if err != nil { return nil, err } - c := saferio.SliceCap((*Load)(nil), uint64(f.Ncmd)) + c := saferio.SliceCap[Load](uint64(f.Ncmd)) if c < 0 { return nil, &FormatError{offset, "too many load commands", nil} } @@ -472,7 +472,7 @@ func NewFile(r io.ReaderAt) (*File, error) { func (f *File) parseSymtab(symdat, strtab, cmddat []byte, hdr *SymtabCmd, offset int64) (*Symtab, error) { bo := f.ByteOrder - c := saferio.SliceCap((*Symbol)(nil), uint64(hdr.Nsyms)) + c := saferio.SliceCap[Symbol](uint64(hdr.Nsyms)) if c < 0 { return nil, &FormatError{offset, "too many symbols", nil} } -- cgit v1.3-5-g9baa