feat(cgo): add byte-slice support to Call arguments
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
7588b3d1de
commit
375d522b1a
2 changed files with 14 additions and 0 deletions
|
|
@ -177,6 +177,15 @@ func TestCallSupportsCUintptrArgument(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCallSupportsByteSliceArgument(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
payload := []byte("agent")
|
||||
if err := Call(callSumLengthFunction(), payload, SizeT(len(payload))); err != nil {
|
||||
t.Fatalf("expected success, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrnoMapping(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
|||
|
|
@ -819,6 +819,11 @@ func toSyscallArg(value interface{}) (uintptr, bool) {
|
|||
return 0, true
|
||||
}
|
||||
return 0, false
|
||||
case []byte:
|
||||
if len(typed) == 0 {
|
||||
return 0, true
|
||||
}
|
||||
return uintptr(unsafe.Pointer(&typed[0])), true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue