(a) Where the defendant in a criminal prosecution is brought before any circuit or criminal judge on a writ of habeas corpus, and discharged by the judge, the costs shall be paid as in other state cases, when the defendant is tried and acquitted by a jury.
(b)

(1) When the defendant in the cases provided for in this section is charged with a felony, the judge shall make out and certify the bill of costs, and deliver the same to the clerk of the circuit court before which the defendant is bound to appear, by whom the costs shall be collected and paid out as in other cases.
(2) If the defendant is charged with a misdemeanor, the judge shall deliver the bill of costs, made out and certified as before, to the court of general sessions of the county in which the defendant was charged with committing the offense, by whom the same shall be allowed as in other cases.