[mamory] Fix -Werror=incompatible-pointer-types , cast return type properly