Align
rafacustodio opened this issue · 8 comments
Good morning (from Brazil)
I'm using this library to create a new RMQ connector in NodeJS, and I'm using the Python Pika as example, but on unpack, the align variable is getting the wrong position from buffer, why do I need that align variable?
What do you mean by align
variable? The alignment of the pointers in memory?
Yes. I've commented the position calculation and now it's getting the right position
align = op[1];
position = Math.ceil(position / align) * align;
>BHL
Well, this way it won't know at all what it's reading...
Could you paste in here a sample buffer, the format, and the expected output?
(Also - x64/x86 ?)
Sorry for the delay
Here is the base64 from the data received from the RMQ socket AQAAAAAB7Q==
, it's from 0 to 7, just the header
The struct unpack must be >BHL
, the expected output is [1, 0, 493]
Well, there's something wrong here. As the alignment for H (unsigned short) is 2, and it comes after a single bytes, which means there should be an extra 0 between the B data and the H data.
Your data is missing a zero...
Wrong:
B 01 00 H 00 00 L 00 01 ed
Correct:
B 01 00 H 00 00 L 00 00 01 ed
Ok, my mistake.
https://github.com/python-git/python/blob/master/Modules/_struct.c
Here we can see that the "standard alignment" actually means "no alignment"
Fixed here: 8a228af
Releasing...
Thank you