mirror of
https://github.com/golang/go
synced 2024-09-30 04:34:33 -06:00
address review issue
This commit is contained in:
parent
51302b36b8
commit
ca30bcce45
@ -121,12 +121,11 @@ func SliceCap(v any, c uint64) int {
|
||||
if typ.Kind() != reflect.Ptr {
|
||||
panic("SliceCap called with non-pointer type")
|
||||
}
|
||||
size := typ.Elem().Size()
|
||||
total := uintptr(c) * size
|
||||
if size > 0 && total/size != uintptr(c) {
|
||||
size := uint64(typ.Elem().Size())
|
||||
if size > 0 && c > (1<<64-1)/size {
|
||||
return -1
|
||||
}
|
||||
if total > chunk {
|
||||
if c*size > chunk {
|
||||
c = uint64(chunk / size)
|
||||
if c == 0 {
|
||||
c = 1
|
||||
|
Loading…
Reference in New Issue
Block a user