2015-06-04 07:22:38 +02:00
|
|
|
|
|
|
|
module Padding
|
|
|
|
|
|
|
|
# objects only come in lengths of multiple of 8 words
|
2015-11-03 15:22:50 +01:00
|
|
|
# but there is a constant overhead of 1 words for layout
|
2015-06-04 07:22:38 +02:00
|
|
|
# and as we would have to subtract 1 to make it work without overhead, we now have to add 7
|
|
|
|
def padded len
|
2015-11-03 15:22:50 +01:00
|
|
|
a = 32 * (1 + (len + 3)/32 )
|
2015-06-04 07:22:38 +02:00
|
|
|
#puts "#{a} for #{len}"
|
|
|
|
a
|
|
|
|
end
|
|
|
|
|
|
|
|
def padded_words words
|
|
|
|
padded(words*4) # 4 == word length, a constant waiting for a home
|
|
|
|
end
|
|
|
|
|
|
|
|
def padding_for length
|
2015-11-03 15:22:50 +01:00
|
|
|
pad = padded(length) - length - 4 # for header, layout
|
2015-06-04 07:22:38 +02:00
|
|
|
pad
|
|
|
|
end
|
|
|
|
end
|