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.

I am of the same opinion, and I manifested that to @aktau when doing the previous changes to try_malloc.
But once done, here I just want all functions to have the same style.
So, if you and @aktau agree, I can modify this to a third version using local vars for the effective value of params, leaving params unmodified and declared const if possible.