Conversation
…ode's buffer. v8::ArrayBuffer can work on an external buffer without owning it. Closes intel#90
|
@tingshao I've updated the impl of ArrayBuffer, there are a few changes, including a revert of your previous PR which make ArrayBuffer be a persistent member variable of NanXXX wrapper class. The reason of the revert is that we sometimes need to update the buffer length, but with your previous PR, there is no way we can update it since it's cached only once. |
| private: | ||
| void CopyFrom(const ArrayBufferHelper& rhs) { | ||
| if (this != &rhs) { | ||
| data_ = rhs.data_; |
There was a problem hiding this comment.
Would the buffer copy using assign cause multiple free if the mode is internal?
There was a problem hiding this comment.
Yes if external_buffer_ is false, then there can be double delete problem, unless user explicitly change one object and set its external_buffer to true
Can there be an automatically approach to avoid this?
There was a problem hiding this comment.
Can we remove the const to change the rhs? Seems not compatible with the coding style. :)
There was a problem hiding this comment.
How about we rename the class to ExternalArrayBuffer and make it only work in external buffer mode?
ArrayBuffers with ownership of buffer will be treated in other class, to avoid potential issues.
There was a problem hiding this comment.
The choice of whether ExternalArrayBuffer or InternalArrayBuffer is made only in impl code right? I'm ok with that.
No description provided.