github.com/ugorji/go/codec@v1.2.13-0.20240307214044-07c54c229a5a/goversion_makemap_unsafe_gte_go110.go (about)

     1  // Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
     2  // Use of this source code is governed by a MIT license found in the LICENSE file.
     3  
     4  //go:build go1.10 && !safe && !codec.safe && !appengine
     5  // +build go1.10,!safe,!codec.safe,!appengine
     6  
     7  package codec
     8  
     9  import (
    10  	"reflect"
    11  	"unsafe"
    12  )
    13  
    14  func makeMapReflect(typ reflect.Type, size int) (rv reflect.Value) {
    15  	t := (*unsafeIntf)(unsafe.Pointer(&typ)).ptr
    16  	urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
    17  	urv.typ = t
    18  	urv.flag = uintptr(reflect.Map)
    19  	urv.ptr = makemap(t, size, nil)
    20  	return
    21  }
    22  
    23  //go:linkname makemap runtime.makemap
    24  //go:noescape
    25  func makemap(typ unsafe.Pointer, size int, h unsafe.Pointer) unsafe.Pointer