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

Remove Buffer cast method #3

Merged
merged 2 commits into from
Jan 16, 2021
Merged

Remove Buffer cast method #3

merged 2 commits into from
Jan 16, 2021

Conversation

jsatka
Copy link

@jsatka jsatka commented Jan 15, 2021

Buffer objects should actually never be cloned because it will result in double free when the original and typecasted Buffer objects are dropped. Pardon for this bug introduced in my previous pull request.

A better way is to cast the data of another type to correct type before writing to a Buffer, and when reading, doing the type cast after reading from the Buffer to result array. This should also be more explicit in the code.

Buffer objects should never be cloned because it will result in double free when the objects are dropped.
Buffer PhantomData type field does not need to be interacted with, thus remove unnecessary pub modifier.
@kenba kenba merged commit 556fecf into kenba:main Jan 16, 2021
@kenba
Copy link
Owner

kenba commented Jan 16, 2021

It may be possible to avoid the double free by calling clRetainMemObject. However, I'm happy to go with the simpler solution and remove the Buffer cast method.

Please, in future can you raise items as issues instead of pull requests?

@jsatka
Copy link
Author

jsatka commented Jan 16, 2021

Okay, will go the issue way in future!

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

Successfully merging this pull request may close these issues.

2 participants