Use round up function.

This commit is contained in:
chriseth
2021-01-14 21:01:43 +00:00
committed by Alex Beregszaszi
parent 6ad0ea9f23
commit 7d6331e26f
5 changed files with 11 additions and 9 deletions
+2 -2
View File
@@ -2056,8 +2056,7 @@ string YulUtilFunctions::arrayAllocationSizeFunction(ArrayType const& _type)
// Make sure we can allocate memory without overflow
if gt(length, 0xffffffffffffffff) { <panic>() }
<?byteArray>
// round up
size := and(add(length, 0x1f), not(0x1f))
size := <roundUp>(length)
<!byteArray>
size := mul(length, 0x20)
</byteArray>
@@ -2070,6 +2069,7 @@ string YulUtilFunctions::arrayAllocationSizeFunction(ArrayType const& _type)
w("functionName", functionName);
w("panic", panicFunction(PanicCode::ResourceError));
w("byteArray", _type.isByteArray());
w("roundUp", roundUpFunction());
w("dynamic", _type.isDynamicallySized());
return w.render();
});