Memory functions improvements: Make style homogeneous.

`try_malloc` was changed in 8bb2c2c0742c57150655e18cf8418a758cebdce8 to
avoid a warning when size is 0.

Code style was also improved on suggestion by @aktau.
This just applies the same style improvements to other similar
functions, to keep code homogeneous.
I think reassigning argument values is something we want to avoid. In fact, can't we make the parameters `const`?