MCPcopy Create free account
hub / github.com/argotorg/solidity / finalizeAllocationFunction

Method finalizeAllocationFunction

libsolidity/codegen/YulUtilFunctions.cpp:3256–3274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3254}
3255
3256std::string YulUtilFunctions::finalizeAllocationFunction()
3257{
3258 std::string functionName = "finalize_allocation";
3259 return m_functionCollector.createFunction(functionName, [&]() {
3260 return Whiskers(R"(
3261 function <functionName>(memPtr, size) {
3262 let newFreePtr := add(memPtr, <roundUp>(size))
3263 // protect against overflow
3264 if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { <panic>() }
3265 mstore(<freeMemoryPointer>, newFreePtr)
3266 }
3267 )")
3268 ("functionName", functionName)
3269 ("freeMemoryPointer", std::to_string(CompilerUtils::freeMemoryPointer))
3270 ("roundUp", roundUpFunction())
3271 ("panic", panicFunction(PanicCode::ResourceError))
3272 .render();
3273 });
3274}
3275
3276std::string YulUtilFunctions::zeroMemoryArrayFunction(ArrayType const& _type)
3277{

Callers 2

endVisitMethod · 0.80

Calls 4

WhiskersClass · 0.85
renderMethod · 0.80
to_stringFunction · 0.50
createFunctionMethod · 0.45

Tested by

no test coverage detected