That would be known as writing you a citation, and I believe you have to have less than 3 grams in order for them to write you that. BUT it is at the DISCRETION of the police officer, and if they decide to arrest you, the penalty is 180 days in jail and a $1000 fine.

I am near Austin, and I have known of plenty of people getting arrested for marijuana though, so it's not THAT safe.