From 7e460e70d90295cf08ea627c0a0fff170aba5518 Mon Sep 17 00:00:00 2001 From: Martin Möhrmann Date: Wed, 20 Apr 2016 18:00:52 +0200 Subject: runtime: use type int to specify size for newarray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consistently use type int for the size argument of runtime.newarray, runtime.reflect_unsafe_NewArray and reflect.unsafe_NewArray. Change-Id: Ic77bf2dde216c92ca8c49462f8eedc0385b6314e Reviewed-on: https://go-review.googlesource.com/22311 Reviewed-by: Keith Randall Run-TryBot: Martin Möhrmann TryBot-Result: Gobot Gobot --- src/runtime/malloc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 95d24a467a..30f2a4fca5 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -770,16 +770,16 @@ func reflect_unsafe_New(typ *_type) unsafe.Pointer { return newobject(typ) } -// implementation of make builtin for slices -func newarray(typ *_type, n uintptr) unsafe.Pointer { - if int(n) < 0 || n > maxSliceCap(typ.size) { +// newarray allocates an array of n elements of type typ. +func newarray(typ *_type, n int) unsafe.Pointer { + if n < 0 || uintptr(n) > maxSliceCap(typ.size) { panic(plainError("runtime: allocation size out of range")) } - return mallocgc(typ.size*n, typ, true) + return mallocgc(typ.size*uintptr(n), typ, true) } //go:linkname reflect_unsafe_NewArray reflect.unsafe_NewArray -func reflect_unsafe_NewArray(typ *_type, n uintptr) unsafe.Pointer { +func reflect_unsafe_NewArray(typ *_type, n int) unsafe.Pointer { return newarray(typ, n) } -- cgit v1.3-5-g9baa