Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

buffer: introduce Buffer#toArrayBuffer() API #6337

Merged
merged 2 commits into from
Oct 11, 2013
Merged

buffer: introduce Buffer#toArrayBuffer() API #6337

merged 2 commits into from
Oct 11, 2013

Conversation

trevnorris
Copy link

This also includes a few small fixes.

#undef CHECK_NOT_OOB
#undef ARGS_THIS
#undef SLICE_START_END

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#undef'ing these isn't necessary, because the macros don't potentially conflict with anything else in the file, nor will they conflict with anyone else in the build system unless someone #include <node_buffer.cc> which would almost certainly cause symbol conflicts in their build since this file doesn't have include guards :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh duh. I'm thinking headers here. working on async-wrap.h and async-wrap-inl.h for so long has warped me a little.

Because it's possible for the data within a Buffer instance to be
altered after instantiation, or in case a user attempts to do something
like the following:

Buffer.prototype.fill.call({}, 10, 0, 10);

It doesn't result in a segfault.
@tjfontaine
Copy link

I'm basically +1 on this, I think there are more ways we can improve Buffer/ArrayBuffer interactions

@trevnorris trevnorris merged commit ad83620 into nodejs:master Oct 11, 2013
@xdenser
Copy link

xdenser commented May 12, 2014

var buf = new Buffer(1024*1024);
setInterval(function(){
 var b = new Uint8Array(buf.toArrayBuffer());
},10);

eats memory like crazy

@trevnorris
Copy link
Author

@xdenser thanks. posted as official issue in #7609. Looking into it right away.

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

Successfully merging this pull request may close these issues.

None yet

3 participants