Move C memory function to global namespace and properly export them for C linkage
Fix something which is pretty unlikely to be a bug
Move wrappers to bottom