combined allocation and gc registration into one, made ANSI compatible