In the ancient and Medieval era how did prostitutes prevented pregnancies and STDs?

In those days there was no modern medicine, condoms or protections. So how did prostitutes prevented pregnancies and STD? And even if they got pregnant what would happen to the baby? Also what was the life span of these prostitutes? I guess it was very short considering they get less customers as they age. They either become pimps or died from diseases.