Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
free allocated strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc authored and sbinet committed Mar 27, 2018
1 parent bd44a9e commit f976f61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ import "C"

import (
"os"
"unsafe"
)

// FromFile converts a Go file to Python file object.
// Calling close from Python will not close a file descriptor.
func FromFile(f *os.File, mode string) *PyObject {
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), C.CString(f.Name()), C.CString(mode))
cname := C.CString(f.Name())
cmode := C.CString(mode)
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), cname, cmode)
C.free(unsafe.Pointer(cname))
C.free(unsafe.Pointer(cmode))
return togo(p)
}

Expand Down

0 comments on commit f976f61

Please sign in to comment.