diff options
| author | lhchavez <[email protected]> | 2020-06-21 06:44:06 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-21 06:44:06 -0700 |
| commit | 619a9c236bf79c63d955490c0803833004a47154 (patch) | |
| tree | f855ae2693c23786852e7be85b7213045000ebe5 /handles.go | |
| parent | 9eaf4fed5f4f2361898f9da8345b34886076bfc2 (diff) | |
Add a way to cleanly shut down the library (#578)
This change adds the Shutdown() method, so that the library can be
cleanly shut down. This helps significanly reduce the amount of noise in
the leak detector.
Diffstat (limited to 'handles.go')
| -rw-r--r-- | handles.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -43,6 +43,16 @@ func (v *HandleList) Untrack(handle unsafe.Pointer) { v.Unlock() } +// Clear stops tracking all the managed pointers. +func (v *HandleList) Clear() { + v.Lock() + for handle := range v.handles { + delete(v.handles, handle) + C.free(handle) + } + v.Unlock() +} + // Get retrieves the pointer from the given handle func (v *HandleList) Get(handle unsafe.Pointer) interface{} { v.RLock() |
