diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-08 04:54:34 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-08-09 06:44:43 +0800 |
commit | 1fb3da6b5325497ea18f17dc61cf50aed7bcfc95 (patch) | |
tree | c9e533abce373fac3fcd4226f516e2b8e0426222 /packages/contracts/src/2.0.0/protocol/Exchange/libs | |
parent | 970bef717e422ac79901300b56ac8f11d3593685 (diff) | |
download | dexon-0x-contracts-1fb3da6b5325497ea18f17dc61cf50aed7bcfc95.tar.gz dexon-0x-contracts-1fb3da6b5325497ea18f17dc61cf50aed7bcfc95.tar.zst dexon-0x-contracts-1fb3da6b5325497ea18f17dc61cf50aed7bcfc95.zip |
Increment free memory pointer for internal Exchange functions that use asm
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol/Exchange/libs')
-rw-r--r-- | packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol index 704c7061c..f047342b3 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol @@ -24,20 +24,17 @@ import "./LibOrder.sol"; contract LibAbiEncoder { - /// @dev ABI encodes calldata for `fillOrder` in memory and returns the address range. - /// This range can be passed into `call` or `delegatecall` to invoke an external - /// call to `fillOrder`. + /// @dev ABI encodes calldata for `fillOrder`. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. - /// @return calldataBegin Memory address of ABI encoded calldata. - /// @return calldataLength Lenfgth of ABI encoded calldata. + /// @return ABI encoded calldata for `fillOrder`. function abiEncodeFillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) - public + internal pure returns (bytes memory fillOrderCalldata) { @@ -207,10 +204,11 @@ contract LibAbiEncoder { } // Set length of calldata - mstore( - fillOrderCalldata, - sub(dataAreaEnd, add(fillOrderCalldata, 0x20)) - ) + let calldataLen := sub(dataAreaEnd, add(fillOrderCalldata, 0x20)) + mstore(fillOrderCalldata, calldataLen) + + // Increment free memory pointer + mstore(0x40, add(fillOrderCalldata, add(calldataLen, 0x20))) } return fillOrderCalldata; |