From 0bbac062b44db5383da377c83ba450c207794a6c Mon Sep 17 00:00:00 2001 From: chenshijun <csj_sky@126.com> Date: 星期一, 16 十二月 2019 17:22:26 +0800 Subject: [PATCH] 修改cgo bug 更新so,解决退出登录问题 --- hikvoice.go | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hikvoice.go b/hikvoice.go index d3a45e1..bd7d514 100644 --- a/hikvoice.go +++ b/hikvoice.go @@ -8,11 +8,24 @@ #include <stdlib.h> #include "Voice.h" - */ import "C" +import ( + "unsafe" +) // SendVoice Send Voice func SendVoice(ip,usrname,passwd,voiceFilePath string) int { - return int(C.SendVoice(C.CString(ip), C.CString(usrname), C.CString(passwd), C.CString(voiceFilePath))) + + cip := C.CString(ip) + defer C.free(unsafe.Pointer(cip)) + cusrname := C.CString(usrname) + defer C.free(unsafe.Pointer(cusrname)) + cpasswd := C.CString(passwd) + defer C.free(unsafe.Pointer(cpasswd)) + cvoiceFilePath := C.CString(voiceFilePath) + defer C.free(unsafe.Pointer(cvoiceFilePath)) + + cRet := C.SendVoice(cip, cusrname, cpasswd, cvoiceFilePath) + return int(cRet) } -- Gitblit v1.8.0