When two or more defendants are included in the same accusatory pleading, and the court is of opinion that in regard to a particular defendant there is not sufficient evidence to put him on his defense, it must order him to be discharged before the evidence is closed, that he may be a witness for his codefendant.
Ca. Pen. Code § 1100