nodejs-std icon indicating copy to clipboard operation
nodejs-std copied to clipboard

haxe.io.Bytes.alloc should initialize the buffer

Open jaromanda opened this issue 11 years ago • 0 comments

All nodejs docs show that

    new Buffer(length);

is uninitialized

However,

    haxe.io.Bytes.alloc(length);

returns an initialized (with 0's) buffer in all targets. While I can't seem to find any documentation to support this, the code in the standard haxe.io.Bytes suggests this to be the case

To maintain consistency, probably should do (at about line 266 in haxe/io/Bytes.hx) :

    #elseif (nodejs || nodejs_std)
        var a = new js.Node.NodeBuffer(length);
        a.fill(0, 0, length);
        return new Bytes(length,a);

instead of

    #elseif (nodejs || nodejs_std)
        return new Bytes(length,new js.Node.NodeBuffer(length));

jaromanda avatar Sep 20 '14 11:09 jaromanda