Losing weight while pregnant is dangerous for your baby. First your baby needs a constant supply of new calories for brain, muscle & bone development. When you lose weight your body will take the calories & nutrients it needs first, leaving your baby to "scavenge" for what it needs. Your baby needs lots of healthy calories. Lots of vitamins & minerals. I would not try to limit my intake of healthy foods, but do recommend avoiding unhealthy foods. Eat lots of veggies, fruits, whole grains, protein, and water. Avoid soda, ice cream, cake, candy,etc. Also avoid 'fake' sugars like those found in diet sodas. They can cross the uterine barrier. It is unknown if they do harm to fetuses, but its not worth the risk. As other posters said, walking is great exercise that will help get your muscles & heart in shape, even if you don't lose weight.
Finally, another reason why it is unsafe to lose weight while pregnant is because when you lose weight the fat molecules in your fat cells are released into your blood stream. (Which will eventually circulate through your baby). Fat molecules are used by the body to store toxins it can't immediately dispose of (toxins could be anything from excess vitamins to mercury - when we eat too much our body can't always keep up with the disposal of these items, so we store them to dispose of later, when we lose weight). So, any fat you lose will carry these toxins through your baby's blood stream too. If your baby is not getting enough nutrients it may try to use the fat for energy for growth, (to get energy from the fat your baby would have to break down the molecule) thus releasing the toxin in its body. A small weight fluctuation during pregnancy (5 - 10lbs) probably wouldn't be an issue. But, I wouldn't try to lose 40lbs. I would recommend trying to eat really healthy & start walking & just try to not gain any weight. Then once the baby is born, continue to eat healthy, up the exercise & start to control your portions.
Good luck.