Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions to safely read from Ptr fields #50

Open
cjay opened this issue Apr 14, 2020 · 1 comment
Open

Functions to safely read from Ptr fields #50

cjay opened this issue Apr 14, 2020 · 1 comment

Comments

@cjay
Copy link
Contributor

cjay commented Apr 14, 2020

I managed to shoot myself in the foot by reading back an array that was set via setListCountAndRef by extracting the Ptr near the end of the lifetime of a struct, followed by reading the array with peekArray. Because the array lifetime is coupled to the struct lifetime, this caused the array to be overwritten sometimes before peekArray was finished.
While that's entirely my fault, it would be nice to have more field accessor functions. I already have some in Program.Foreign: withUnsafeField, getListCountAndRef. (Besides, the function withArrayLen from this module should probably be in Graphics.Vulkan.Marshal). Not making a pull request because I don't know where to put them, and I guess they can be done without IO somehow.

@achirkin
Copy link
Owner

achirkin commented May 1, 2020

Sorry, I did not have time to work this project lately. The suggestion seems very reasonable to me. If you like and have some time, please make a PR and I'd be happy to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants