Skip to content

haxe.io.Bytes.alloc should initialize the buffer #33

@jaromanda

Description

@jaromanda

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions