]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/cgo/handle.go
runtime: add available godoc link
[gostls13.git] / src / runtime / cgo / handle.go
index d711900d7990ee0e509f8db5b2e57523185949d1..59b65da2b6d763aeb8d153ed4ebd7384964f37db 100644 (file)
@@ -61,8 +61,8 @@ import (
 //     }
 //
 // Some C functions accept a void* argument that points to an arbitrary
-// data value supplied by the caller. It is not safe to coerce a cgo.Handle
-// (an integer) to a Go unsafe.Pointer, but instead we can pass the address
+// data value supplied by the caller. It is not safe to coerce a [cgo.Handle]
+// (an integer) to a Go [unsafe.Pointer], but instead we can pass the address
 // of the cgo.Handle to the void* parameter, as in this variant of the
 // previous example:
 //
@@ -106,7 +106,7 @@ type Handle uintptr
 // The intended use is to pass the returned handle to C code, which
 // passes it back to Go, which calls Value.
 func NewHandle(v any) Handle {
-       h := atomic.AddUintptr(&handleIdx, 1)
+       h := handleIdx.Add(1)
        if h == 0 {
                panic("runtime/cgo: ran out of handle space")
        }
@@ -140,5 +140,5 @@ func (h Handle) Delete() {
 
 var (
        handles   = sync.Map{} // map[Handle]interface{}
-       handleIdx uintptr      // atomic
+       handleIdx atomic.Uintptr
 )