tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 2b8a308d0f5d12be61cc505687f6fe64d13aca92
parent 874f74e9e7bddba395bde85dbd1b4d63894a5624
Author: parazyd <parazyd@dyne.org>
Date:   Mon, 29 Oct 2018 17:52:32 +0100

Trim outbuf and errbuf in ZenroomExecToBuf function return.

Diffstat:
Mpkg/damlib/zenroom.go | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/pkg/damlib/zenroom.go b/pkg/damlib/zenroom.go @@ -25,7 +25,11 @@ package damlib // #include <stddef.h> // #include "zenroom.h" import "C" -import "unsafe" + +import ( + "bytes" + "unsafe" +) // ZenroomExec is Zenroom's simple API call. func ZenroomExec(script, conf, keys, data string, verbosity int) int { @@ -42,7 +46,8 @@ func ZenroomExecToBuf(script, conf, keys, data string, verbosity int) (int, []by errbuf := make([]byte, bufsize) return int(C.zenroom_exec_tobuf(C.CString(script), C.CString(conf), - C.CString(keys), C.CString(data), C.int(verbosity), - (*C.char)(unsafe.Pointer(&outbuf[0])), C.size_t(bufsize), - (*C.char)(unsafe.Pointer(&errbuf[0])), C.size_t(bufsize))), outbuf, errbuf + C.CString(keys), C.CString(data), C.int(verbosity), + (*C.char)(unsafe.Pointer(&outbuf[0])), C.size_t(bufsize), + (*C.char)(unsafe.Pointer(&errbuf[0])), C.size_t(bufsize))), + bytes.Trim(outbuf, "\x00"), bytes.Trim(errbuf, "\x00") }