Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
saste opened this issue Apr 17, 2015 · 1 comment
Closed

Comments

@saste
Copy link

saste commented Apr 17, 2015

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

@dcodeIO
Copy link
Member

dcodeIO commented Jun 20, 2015

Missed to push 3.5.5 (which includes this fix) to NPM. Pushed it now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants