Add function attributes to functions in memory.h  #811

Add missing function attributes in memory.h. Fixes #806