From 619a9c236bf79c63d955490c0803833004a47154 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sun, 21 Jun 2020 06:44:06 -0700 Subject: 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. --- git.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'git.go') diff --git a/git.go b/git.go index 0459dde..bd01b6d 100644 --- a/git.go +++ b/git.go @@ -139,6 +139,16 @@ func init() { C.git_openssl_set_locking() } +// Shutdown frees all the resources acquired by libgit2. Make sure no +// references to any git2go objects are live before calling this. +// After this is called, invoking any function from this library will result in +// undefined behavior, so make sure this is called carefully. +func Shutdown() { + pointerHandles.Clear() + + C.git_libgit2_shutdown() +} + // Oid represents the id for a Git object. type Oid [20]byte -- cgit v1.2.3