mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
0dcb026db3
If `kNoZeroFill` is set here, it won't be reset in case of pooled allocation. In case of "slow" allocation it will be set later anyway. Fixes: https://github.com/nodejs/node/issues/6006 PR-URL: https://github.com/nodejs/node/pull/6007 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
25 lines
524 B
JavaScript
25 lines
524 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const safe = Buffer.alloc(10);
|
|
|
|
function isZeroFilled(buf) {
|
|
for (let n = 0; n < buf.length; n++)
|
|
if (buf[n] !== 0) return false;
|
|
return true;
|
|
}
|
|
|
|
assert(isZeroFilled(safe));
|
|
|
|
// Test that unsafe allocations doesn't affect subsequent safe allocations
|
|
Buffer.allocUnsafe(10);
|
|
assert(isZeroFilled(new Float64Array(10)));
|
|
|
|
new Buffer(10);
|
|
assert(isZeroFilled(new Float64Array(10)));
|
|
|
|
Buffer.allocUnsafe(10);
|
|
assert(isZeroFilled(Buffer.alloc(10)));
|