Commit 3a442bfa authored by Lysander Trischler's avatar Lysander Trischler

Free memory

parent 9f5ba127
......@@ -93,8 +93,6 @@ _so.parse_file.restype = ParseFileResult
_so.free_twt_file.argtypes = [ctypes.POINTER(_TwtFile)]
_so.free_twter.argtypes = [ctypes.POINTER(_Twter)]
_so.free_string.argtypes = [ctypes.c_char_p]
......@@ -108,9 +106,7 @@ def parse_file(twtxt_input, twter):
if result.twtfile is None:
return None
return result.twtfile.contents.to_python()
#twtfile = TwtFile()
#if result.twtfile.contents.twter is not None:
# twtfile.twter = result.twtfile.contents.twter.contents.to_python()
#return twtfile
twtfile = result.twtfile.contents.to_python()
_so.free_twt_file(result.twtfile)
return twtfile
......@@ -98,8 +98,7 @@ func free_string(s *C.char) {
}
}
//export free_twter
func free_twter(t *C.struct_twter) {
func freeTwter(t *C.struct_twter) {
if t != nil {
free_string(t.nick)
free_string(t.url)
......@@ -111,7 +110,11 @@ func free_twter(t *C.struct_twter) {
//export free_twt_file
func free_twt_file(t *C.struct_twt_file) {
if t != nil {
free_twter(t.twter)
freeTwter(t.twter)
if t.twts != nil {
C.free(unsafe.Pointer(t.twts))
}
C.free(unsafe.Pointer(t))
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment