A charley horse is a contusion of the upper leg muscle, the quadriceps muscle. It is usually caused by an injury, an impact to the leg by something like a knee, or a horse’s kick, hence the name charley horse. I don’t know who Charlie is though.
Recently the term has expanded to included leg cramps. I believe it is this definition of a charley horse that you are asking about. There are a few reasons for you to get cramps. An obvious reason is just that you may have been working out hard, or playing a game and your muscles are tired. You would obviously know if that were the problem.
The other potential reasons for your nightly leg cramps are: mineral deficiency, dehydration, and hormone imbalance. A mineral deficiency can be helped by taking multivitamins, or by making sure you eat a lot of leafy greens to get some iron. Dehydration is easily fixed by drinking more water. A hormone imbalance would need to be checked out by a doctor, but you should see if getting more iron and water fixes the problem first.
Icing the area that hurts is always a good idea, but it is temporary relief if you have chronic leg cramps.