If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value
with address(this).balance
.
If the balance of the contract prior to calling function send
is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.
Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send
has just transferred to the contract using this function.