diff options
author | chriseth <chris@ethereum.org> | 2018-03-13 22:21:38 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-04-04 18:37:04 +0800 |
commit | 0cbe55005de79b0f7c5c770d50c3eb87df019789 (patch) | |
tree | fc47c0c80cad0a7f70f57b5cefe9c9e7de413d76 /docs/miscellaneous.rst | |
parent | c63efebd4517d51f29082a8d0cff814a4922243d (diff) | |
download | dexon-solidity-0cbe55005de79b0f7c5c770d50c3eb87df019789.tar.gz dexon-solidity-0cbe55005de79b0f7c5c770d50c3eb87df019789.tar.zst dexon-solidity-0cbe55005de79b0f7c5c770d50c3eb87df019789.zip |
Create empty dynamic memory arrays more efficiently.
Diffstat (limited to 'docs/miscellaneous.rst')
-rw-r--r-- | docs/miscellaneous.rst | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 01154854..20400aa2 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -64,12 +64,15 @@ The position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint25 Layout in Memory **************** -Solidity reserves three 256-bit slots: +Solidity reserves four 32 byte slots: -- 0 - 64: scratch space for hashing methods -- 64 - 96: currently allocated memory size (aka. free memory pointer) +- ``0x00`` - ``0x3f``: scratch space for hashing methods +- ``0x40`` - ``0x5f``: currently allocated memory size (aka. free memory pointer) +- ``0x60`` - ``0x7f``: zero slot -Scratch space can be used between statements (ie. within inline assembly). +Scratch space can be used between statements (ie. within inline assembly). The zero slot +is used as initial value for dynamic memory arrays and should never be written to +(the free memory pointer points to ``0x80`` initially). Solidity always places new objects at the free memory pointer and memory is never freed (this might change in the future). |