It is not clear from the facts you recited whether it was legal for him to search your car, though it appears plainly illegal for him to write that you consented to the search of your car.

If he allowed you to remain in your car, then he would have been allowed to search areas within your car that were within arm's reach. The theory is that such a search is necessary for officer safety. (In other situations, the need to preserve evidence is also a reason, but the officer is only entitled to use that reason to search for evidence related to the arrest, which does not apply here.) Such a search is called "search incident to arrest". See Arizona v. Gant (S.Ct. 2009) for details.

If he removed you from the car, and especially if he handcuffed you away from the car, then he is not entitled to make a search incident to arrest. However, if you stopped your car in a place illegal to leave it, or if you stopped it in a legal parking place but did not have another driver handy to drive it away, the police are allowed to use the excuse of "community caretaking" to impound your car, and part of that process is to perform an inventory search. An inventory search is less extensive than a full-blown search.

If the police did not meet either of those two requirements for community caretaking, then they are not allowed to impound your car, even if state law says they may. This is because the Fourth Amendment protects your personal property (effects) from being unreasonably seized without a warrant, and the U.S. Supreme Court has ruled that unless there is a constitutionally "reasonable" purpose for seizing a vehicle (such as community caretaking), such seizures are unreasonable and therefore unconstitutional.

So, depending on circumstances, the police may or may not have been allowed to search your car.

Since it you were arrested for drugs, I suggest you get a lawyer.