Trevor Norris
65249ccd9b
buffer: slow buffer copy compatibility fix
Fix issue where SlowBuffers couldn't be passed as target to Buffer
copy().
Also included checks to see if Argument parameters are defined before
assigning their values. This offered ~3x's performance gain.
Backport of 16bbecc
from master branch. Closes #4633 .
12 years ago
Ben Noordhuis
498200b87c
buffer: reject negative SlowBuffer offsets
Reject negative offsets in SlowBuffer::MakeFastBuffer(), it allows
the creation of buffers that point to arbitrary addresses.
Reported by Trevor Norris.
12 years ago
Bert Belder
a6b8f63660
buffer: zero-length buffers shouldn't be slab-backed
12 years ago
Trevor Norris
6772308883
buffer: Don't double-negate numeric buffer arg
Fix #4331
Using double negate forces values into 32bit space. Because of this
Math.ceil needs to be used. Since NaN comparisons are always false, use
that to our advantage to return 0 if it is.
Also added two tests to verify the changes.
12 years ago
koichik
37f0eb8df3
Revert "buffer: added support for writing NaN and Infinity"
This reverts commit 6b9425fe37
.
12 years ago
koichik
6b9425fe37
buffer: added support for writing NaN and Infinity
to writeDoubleBE(), writeDoubleLE(), writeFloatBE() and writeFloatLE().
Fixes #3934 .
13 years ago
Karl Skomski
57d53a47e8
Use parent SlowBuffer, if any, when Buffer is sliced
Closes #3416
Closes #3477
13 years ago
isaacs
d53cdc5378
Add Buffer.concat method
We write out this loop a lot of places throughout node.
It clearly needs to be an API method.
13 years ago
isaacs
a3753b496e
Revert "Fix #3242 Actually deprecate 'binary' buffer encoding"
This reverts commit 5979f096d1
.
Related:
- #3279
- #3278
13 years ago
isaacs
1665b4a2a3
lint
13 years ago
Nathan Rajlich
38542f76a9
buffer: make SlowBuffer inherit from Buffer
This frees us from manually having to copy over functions to SlowBuffer's
prototype (which has bitten us multiple times in the past).
As an added bonus, the `inspect()` function is now shared between Buffer
and SlowBuffer, removing some duplicate code.
Closes #3228 .
13 years ago
isaacs
5979f096d1
Fix #3242 Actually deprecate 'binary' buffer encoding
13 years ago
koichik
ebbd4039bc
buffer: add UTF-16LE encoding name.
13 years ago
Ben Noordhuis
285d8c6589
buffer: align fast buffers on 8 byte boundary
Prevents alignment issues when people create a typed array from a buffer.
Unaligned loads or stores are less efficent and (on some architectures) unsafe.
13 years ago
Phil Sung
cf2513e1aa
buffer: don't pollute global namespace in buffer.readInt*
13 years ago
Ben Noordhuis
59a9a9b5b0
buffer: add .read*() and .write*() methods to SlowBuffer prototype
Fixes #2138 .
13 years ago
Łukasz Walukiewicz
3b852d7fab
buffer: fix minimum values for writeInt*() functions
13 years ago
Łukasz Walukiewicz
5d0b5a00aa
buffer: fix minimum values for writeInt*() functions
13 years ago
Ben Noordhuis
f6bce20e5e
buffers: handle bad length argument in constructor
Coerce fractional, negative and non-numeric length arguments to numbers.
Fractional numbers are rounded up, negative numbers and non-numeric values
are set to zero.
13 years ago
Ben Noordhuis
d157131439
buffers: handle bad length argument in constructor
Coerce fractional, negative and non-numeric length arguments to numbers.
Fractional numbers are rounded up, negative numbers and non-numeric values
are set to zero.
13 years ago
koichik
526c54c979
buffer: write() should always set _charsWritten.
Fixes #1633 .
13 years ago
Brian White
b7c23ac3f5
Incorporate endianness into buffer.read* function names instead of passing in a boolean flag
14 years ago
Ryan Dahl
2689d262ec
Make buffer.INSPECT_MAX_BYTES public for mscdex
14 years ago
Ryan Dahl
7332c4022f
Truncate Buffer.inspect at 50 bytes
14 years ago
Robert Mustacchi
0df08c6a0c
Endian argument should be a boolean. Signed integers shouldn't run through checks for unsigned integers. Clean up jslint. Provide unchecked uint entry points.
14 years ago
Ryan Dahl
8527f00c3c
Lazy load a few modules
14 years ago
koichik
50e147bd03
Add an optional length argument to Buffer.write()
Fixes #243 .
Fixes #1361 .
14 years ago
Devon Govett
562b469b35
More accurite error messages when writing beyond the length of a Buffer.
Fixes #1336 .
14 years ago
Brian White
e505a1215c
Add reading/writing of floats and doubles from/to buffers
Code for readIEEE754/writeIEEE754 is from jspack: http://code.google.com/p/jspack/
14 years ago
Konstantin Käfer
5e1b7cadb4
Add Buffer::fill method to do memset
Fixes #477 .
14 years ago
Robert Mustacchi
9812e31e8b
Add reading/writing of C integers to buffers
14 years ago
koichik
fcc04e67c8
Fix SlowBuffer.write() with 'ucs2' throws ReferenceError.
14 years ago
Ryan Dahl
038306a6c3
Closes GH-843. Fix SlowBuffer.prototype.slice
14 years ago
Ryan Dahl
6111c17a0e
correct hexSlice end
14 years ago
isaacs
3c9fb3ec1a
Fix invalid end handling for SlowBuffer#hexSlice
14 years ago
Ryan Dahl
ab190d38b7
Fix buffer.toString('hex')
14 years ago
Ryan Dahl
55048cdf79
Update copyright headers
14 years ago
isaacs
0aa1a8a005
Closes GH-695 Add 'hex' encoding to Buffer
14 years ago
isaacs
2e6a263e29
Closes GH-609 Support array-ish args to Buffer ctor
Any array-ish thing (whether a Buffer, an Array, or just an object with
a numeric "length") is interpreted as a list of bytes.
14 years ago
Konstantin Käfer
9e101f2b01
UCS-2 support
Closes GH-644.
14 years ago
Ryan Dahl
97e13748fa
Typos
Closes GH-557.
Closes GH-539.
14 years ago
Ryan Dahl
db78043d52
lint
14 years ago
Ryan Dahl
aed0ba3211
buffer.copy targetStart defaults to 0
14 years ago
Ryan Dahl
6d7242b485
Document defaults for buffer.copy()
14 years ago
Ryan Dahl
4f32a59307
Fix buffer.slice(0, 0)
14 years ago
Stéphan Kochen
57eb5cb9a0
Make SlowBuffer pass Buffer.isBuffer test.
14 years ago
Ryan Dahl
515f006b6e
Add legacy methods to Buffer
14 years ago
Ryan Dahl
cf1db4f304
base64 decode should handle whitespace
14 years ago
Ryan Dahl
77fc61d539
Default value for second arg of Buffer#slice
14 years ago
Ryan Dahl
b8bfbdab48
Rename SlowBuffer in binding
15 years ago