I used to get leg cramps every day. My body wasn't getting enough sodium. If you get them often try drinking a cup of chicken (or beef, w/e) bullion before bed. Ideally 2000mg is fine, which I think is 16oz (you can double up the bullion cubes, it's fine, just don't drink the last bit unless you want EXTREME CHICKEN FLAVOR). You can also find sodium in other foods, but I didn't want to change my diet so now I just have a bit of chicken broth before bed. Haven't had leg cramps in a whole year! You can also try magnesium and potassium, if you have ultra cramps, but I find chicken broth works best.
If you're stuck in a cramp, try to stand up and put weight on your heel. Stretch your heel forwards (or try touching your toes to your knee) and roll your heel around in a circular motion. Make sure to do this SLOWLY so that you don't rip the muscle. If you bend your knee (tucking the calf toward you) you can also rip your muscle, like I did three years ago and now I still can't fully extend that leg without calf pain -- so don't do it! This exercise also helps to unlock the muscle if it's still stiff from a night of cramping.
I totally sound like a commercial but w/e cramping sucks :<