@@ -9,21 +9,25 @@ import (
99 "unsafe"
1010)
1111
12- // Pinner represents a set of pinned Go objects. An object can be pinned with
12+ // A Pinner is a set of pinned Go objects. An object can be pinned with
1313// the Pin method and all pinned objects of a Pinner can be unpinned with the
1414// Unpin method.
1515type Pinner struct {
1616 * pinner
1717}
1818
19- // Pin a Go object. The object will not be moved or freed by the garbage
20- // collector until the Unpin method has been called. The pointer to a pinned
19+ // Pin pins a Go object, preventing it from being moved or freed by the garbage
20+ // collector until the Unpin method has been called.
21+ //
22+ // A pointer to a pinned
2123// object can be directly stored in C memory or can be contained in Go memory
22- // passed to C functions. If the pinned object iftself contains pointers to Go
24+ // passed to C functions. If the pinned object itself contains pointers to Go
2325// objects, these objects must be pinned separately if they are going to be
24- // accessed from C code. The argument must be a pointer of any type or an
25- // unsafe.Pointer. It must be a pointer to an object allocated by calling new,
26- // by taking the address of a composite literal, or by taking the address of a
26+ // accessed from C code.
27+ //
28+ // The argument must be a pointer of any type or an
29+ // unsafe.Pointer. It must be the result of calling new,
30+ // taking the address of a composite literal, or taking the address of a
2731// local variable. If one of these conditions is not met, Pin will panic.
2832func (p * Pinner ) Pin (pointer any ) {
2933 if p .pinner == nil {
@@ -59,7 +63,7 @@ func (p *Pinner) Pin(pointer any) {
5963 p .refs = append (p .refs , ptr )
6064}
6165
62- // Unpin all pinned objects of the Pinner.
66+ // Unpin unpins all pinned objects of the Pinner.
6367func (p * Pinner ) Unpin () {
6468 p .pinner .unpin ()
6569
0 commit comments