standardize memory allocation functions

Reviewer: trivial