Skip to content

Commit 8ddcb36

Browse files
committed
dataVisitorDispatch() adjusted to changed obx_data_visitor signature
1 parent 401c4dd commit 8ddcb36

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

objectbox/datavisitorc.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ import (
3030
"unsafe"
3131
)
3232

33+
// "Implements" the C function obx_data_visitor and dispatches to the registered Go data visitor.
3334
// This function finds the data visitor (based on the pointer to the visitorId) and calls it with the given data
3435
// NOTE: don't change ptr contents, it's `const void*` in C but go doesn't support const pointers
3536
//
3637
//export dataVisitorDispatch
37-
func dataVisitorDispatch(visitorIdPtr unsafe.Pointer, data unsafe.Pointer, size C.size_t) C.bool {
38-
if visitorIdPtr == nil {
38+
func dataVisitorDispatch(data unsafe.Pointer, size C.size_t, userData unsafe.Pointer) C.bool {
39+
if userData == nil {
3940
panic("Internal error: visitor ID pointer is nil")
4041
}
41-
var visitorId = *(*uint32)(visitorIdPtr)
42+
var visitorId = *(*uint32)(userData)
4243

4344
// create an empty byte slice and map the C data to it, no copy required
4445
var bytes []byte
@@ -48,7 +49,7 @@ func dataVisitorDispatch(visitorIdPtr unsafe.Pointer, data unsafe.Pointer, size
4849

4950
var fn = dataVisitorLookup(visitorId)
5051
if fn == nil {
51-
panic(fmt.Sprintf("Internal error: data visitor not found for ID: %d", visitorId))
52+
panic(fmt.Sprintf("Internal error: no data visitor found for ID %d", visitorId))
5253
}
5354

5455
return C.bool(fn(bytes))

0 commit comments

Comments
 (0)