From c00a05586b63df56a2c619e456229c1c9f785fa7 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Wed, 10 Jun 2015 13:03:53 +0200 Subject: Make the network code use handles This wasn't ported together with the rest, but it does exhibit the same issues, so let's port it over now. --- clone.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'clone.go') diff --git a/clone.go b/clone.go index b796b6e..4de4aea 100644 --- a/clone.go +++ b/clone.go @@ -28,18 +28,20 @@ func Clone(url string, path string, options *CloneOptions) (*Repository, error) cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) - var copts C.git_clone_options - populateCloneOptions(&copts, options) - defer freeCheckoutOpts(&copts.checkout_opts) + copts := (*C.git_clone_options)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_clone_options{})))) + populateCloneOptions(copts, options) if len(options.CheckoutBranch) != 0 { copts.checkout_branch = C.CString(options.CheckoutBranch) - defer C.free(unsafe.Pointer(copts.checkout_branch)) } runtime.LockOSThread() defer runtime.UnlockOSThread() - ret := C.git_clone(&repo.ptr, curl, cpath, &copts) + ret := C.git_clone(&repo.ptr, curl, cpath, copts) + freeCheckoutOpts(&copts.checkout_opts) + C.free(unsafe.Pointer(copts.checkout_branch)) + C.free(unsafe.Pointer(copts)) + if ret < 0 { return nil, MakeGitError(ret) } -- cgit v1.2.3