fixed bug where 4 bytes of data would be written with only 3 expected.

This commit is contained in:
Michael Hrivnak 2012-10-23 19:49:23 -04:00 committed by Michael Hrivnak
parent 1abcc9b425
commit e6bef92ab7

View file

@ -390,6 +390,10 @@ if $0 == __FILE__
else else
bits = Math.log(node_count, 2).ceil bits = Math.log(node_count, 2).ceil
bytes = (bits / 8).ceil bytes = (bits / 8).ceil
if bytes == 3
# must write this as a 32-bit int
bytes = 4
end
file.write([128 + bytes].pack("C")) file.write([128 + bytes].pack("C"))
# get the correct integer directive for pack() # get the correct integer directive for pack()
@ -400,7 +404,7 @@ if $0 == __FILE__
when 2 when 2
# 16-bit unsigned big-endian # 16-bit unsigned big-endian
directive = "n" directive = "n"
when 3..4 when 4
# 32-bit unsigned big-endian # 32-bit unsigned big-endian
directive = "N" directive = "N"
else else