Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Weird offset computation when using the ByteBuffer.writeCString() method #46

Closed
@saste

Description

@saste

I'm using ByteBuffer to fill a buffer with string data:

d = new dcodeIO.ByteBuffer()
Object { buffer: ArrayBuffer, view: DataView, offset: 0, markedOffset: -1, limit: 16, littleEndian: false, noAssert: false }
d.writeCString("aaa")
Object { buffer: ArrayBuffer, view: DataView, offset: 4, markedOffset: -1, limit: 16, littleEndian: false, noAssert: false }
d.writeCString("bbb")
Object { buffer: ArrayBuffer, view: DataView, offset: 4, markedOffset: -1, limit: 16, littleEndian: false, noAssert: false }
d.writeCString("ccc")
Object { buffer: ArrayBuffer, view: DataView, offset: 4, markedOffset: -1, limit: 16, littleEndian: false, noAssert: false }

As you can see the offset is only updated after the first operation, while all successive operations will leave the same offset, so that the third write will overwrite the content written by the second one.

If I use writeUTF8String() it is working as expected, that is the offset is correctly updated after the second write.
Is it a defect or am I missing something obvious?

TIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions