What was the main purpose of the Black Codes?

ATo allow black people to get married and to vote
BTo restrict freedom for black people
CTo protect black people from unfair laws
DTo provide sharecropping jobs