github.com/moontrade/unsafe@v0.9.1/memory/alloc_gc.go (about)

     1  //go:build !tinygo && !wasm && !wasi && !tinygo.wasm
     2  
     3  package memory
     4  
     5  import (
     6  	"unsafe"
     7  )
     8  
     9  //go:linkname mallocgc runtime.mallocgc
    10  func mallocgc(size uintptr, typ unsafe.Pointer, needzero bool) unsafe.Pointer
    11  
    12  func GCAlloc(size uintptr) unsafe.Pointer {
    13  	return mallocgc(size, nil, false)
    14  	//b := make([]byte, size)
    15  	//return unsafe.Pointer(&b[0])
    16  }
    17  
    18  func GCAllocZeroed(size uintptr) unsafe.Pointer {
    19  	return mallocgc(size, nil, true)
    20  }