MCPcopy
hub / github.com/tinygo-org/tinygo / Put

Method Put

cgo/sync.go:21–30  ·  view source on GitHub ↗

Put stores a value in the map. It can later be retrieved using Get. It must be removed using Remove to avoid memory leaks.

(v interface{})

Source from the content-addressed store, hash-verified

19// Put stores a value in the map. It can later be retrieved using Get. It must
20// be removed using Remove to avoid memory leaks.
21func (m *refMap) Put(v interface{}) unsafe.Pointer {
22 m.lock.Lock()
23 defer m.lock.Unlock()
24 if m.refs == nil {
25 m.refs = make(map[unsafe.Pointer]interface{}, 1)
26 }
27 ref := C.malloc(1)
28 m.refs[ref] = v
29 return ref
30}
31
32// Get returns a stored value previously inserted with Put. Use the same
33// reference as you got from Put.

Callers

nothing calls this directly

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected