Callback test/example uses strlen() but gets passed a go string which afaik aren't NUL terminated #316
-
Probably a beginners question but here you go: I was trying to find a basic example of callback from C to Go (I didn't in examples/ btw, could be worth adding) but I did find the test: https://github.com/ebitengine/purego/blob/main/callback_test.go#L46 and https://github.com/ebitengine/purego/blob/main/testdata/libcbtest/callback_test.c#L8 how does the go side string end up being a c side pointer without a length and how does it get NUL terminated... what if the string had NULs in it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Did you check the docs? There's a basic example there:
It's copied in the background to add a nul terminator. See internal/strings |
Beta Was this translation helpful? Give feedback.
Did you check the docs? There's a basic example there:
https://pkg.go.dev/github.com/ebitengine/purego?GOOS=darwin#example-NewCallback
It's copied in the background to add a nul terminator. See internal/strings