switch over hooks to SafeMalloc