-
Notifications
You must be signed in to change notification settings - Fork 28
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
safety improvement to Memory #167
base: master
Are you sure you want to change the base?
Conversation
We could preserve the ptr field also, but seems unlikely to make a difference in practice and adds some mildly annoying duplication of storage bytes. In Julia v1.11, this field could be replaced in whole or in part by a Memory{UInt8} object allocation, but currently `jl_string_to_genericmemory` is not even exposed as an API in Base.
If I want to use the "transcoding protocol" to decompress data directly into a
|
It is generally not a good idea to use However, the IO protocol in Base is mostly based around calling |
But anyways, that documentation is sort of a lie there, since that is not really how anything seems to be implemented here. Nor would it be even be that sensible to implement that way. Everything is required to go through the Buffer object (a Vector) and only that object ever gets converted to Memory (basically, a slower, less-safe view of said Buffer). For example: TranscodingStreams.jl/src/stream.jl Lines 681 to 697 in d7e8370
sloweof implementation
|
While Memory was in theory a slightly safer wrapper for
unsafe_read
/unsafe_write
operations, it doesn't appear to have every needed to be used that way, and ways just took in Vector{UInt8}. That seems safer to keep it that way therefore.Closes #125