Content-Length: 272241 | pFad | http://github.com/sbinet/go-python/commit/f976f61134dc6f5b4920941eb1b0e7cec7e4ef4c

22 free allocated strings · sbinet/go-python@f976f61 · GitHub
Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit f976f61

Browse files
dennwcsbinet
authored andcommitted
free allocated strings
1 parent bd44a9e commit f976f61

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

file.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ import "C"
1717

1818
import (
1919
"os"
20+
"unsafe"
2021
)
2122

2223
// FromFile converts a Go file to Python file object.
2324
// Calling close from Python will not close a file descriptor.
2425
func FromFile(f *os.File, mode string) *PyObject {
25-
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), C.CString(f.Name()), C.CString(mode))
26+
cname := C.CString(f.Name())
27+
cmode := C.CString(mode)
28+
p := C._gopy_PyFile_FromFile(C.int(f.Fd()), cname, cmode)
29+
C.free(unsafe.Pointer(cname))
30+
C.free(unsafe.Pointer(cmode))
2631
return togo(p)
2732
}
2833

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sbinet/go-python/commit/f976f61134dc6f5b4920941eb1b0e7cec7e4ef4c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy