Preparation of halogenated hydrocarbons by reactions not affecting the number of carbon or of halogen atoms in the reaction