Skip to content

Callback test/example uses strlen() but gets passed a go string which afaik aren't NUL terminated #316

Answered by TotallyGamerJet
ldemailly asked this question in Q&A
Discussion options

You must be logged in to vote

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:

Did you check the docs? There's a basic example there:
https://pkg.go.dev/github.com/ebitengine/purego?GOOS=darwin#example-NewCallback

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?

It's copied in the background to add a nul terminator. See internal/strings

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ldemailly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants