Update mem_retain to return the retained pointer