Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is not the right solution.
If we pass a pointer here, after
setCommonOpts
blob
will be freed, and the pointer will be a dangling pointer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give more context how we can reproduce your issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry didn't give more details, was a bit late here. I'll make a small reproducible example this weekend.
Curl internally copies the struct we pass to it so it doesn't dangle https://github.com/curl/curl/blob/b8c12634fce509673f8eda657e9a2222890707c1/lib/setopt.c#L81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying, it seems the examples used in docs also pass in pointer.
So it's zig to convert struct to pointer automatically before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked what the signature of the translated C code is but the type must coalesce to both a pointer and struct.
My guess is some sort of
anytype
(I'm still pretty new to zig so should verify this)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the CI pass, I will merge it now.
You can update here when you figure out how it works before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as an update I haven't managed to figure out why this works on macOS but not on my raspberry pi, and won't look into it any further. The
curl_easy_setopt
is variadic. Somehow on macOS it's happy to take our blob struct and pass the pointer to curl whereas when compiled for linux it's not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for update.
For anyone interested, this is what zig translate-c output.