Allocate memory for correct type.