2015-06-04 07:22:38 +02:00
|
|
|
|
|
|
|
module Padding
|
|
|
|
|
2015-11-15 19:42:07 +01:00
|
|
|
# objects only come in lengths of multiple of 8 words / 32 bytes
|
|
|
|
# and there is a "hidden" 1 word that is used for debug/check memory corruption
|
2015-06-04 07:22:38 +02:00
|
|
|
def padded len
|
2015-11-15 19:42:07 +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
|
2016-02-25 20:50:10 +01:00
|
|
|
pad = padded(length) - length # for header, type
|
2015-06-04 07:22:38 +02:00
|
|
|
pad
|
|
|
|
end
|
|
|
|
end
|