Stability for functional-differential equations and some variational problems