MCPcopy
hub / github.com/uber/aresdb / DoCGoCall

Function DoCGoCall

cgoutils/utils.go:26–34  ·  view source on GitHub ↗

DoCGoCall is the function wrapper to call a cgo function, check whether there is any exception thrown by the function and converted it to a golang error if any.

(f func() (uintptr, unsafe.Pointer))

Source from the content-addressed store, hash-verified

24// DoCGoCall is the function wrapper to call a cgo function, check whether there is any exception thrown by the function
25// and converted it to a golang error if any.
26func DoCGoCall(f func() (uintptr, unsafe.Pointer)) uintptr {
27 res, pStrErr := f()
28 if pStrErr != nil {
29 errMsg := C.GoString((*C.char)(pStrErr))
30 C.free(pStrErr)
31 panic(utils.StackError(nil, errMsg))
32 }
33 return res
34}

Callers 2

doCGoCallFunction · 0.92
doCGoCallFunction · 0.85

Calls 1

StackErrorFunction · 0.92

Tested by

no test coverage detected