function _toBytes(address a) internal pure returns (bytes memory b) {
assembly {
let m := mload(0x40)
a := and(a, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
mstore(
add(m, 20),
xor(0x140000000000000000000000000000000000000000, a)
)
mstore(0x40, add(m, 52))
b := m
}
}
bytes 转 address
function _bytesToAddress(bytes memory bys)
internal
pure
returns (address addr)
{
assembly {
addr := mload(add(bys, 20))
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)