Well, the answer needs a proper understanding of the concept of Karma. Hindu philosophy divides Karma into - Prarabdha, Sanchita and Agami.
Sanchita Karma is the store house of all past Karmas. It is our Causal body/Karana sharira.
Prarabdha Karma- refers to those Karma'sKarmas which has started to give results. A person gets a birth, takes on a body based on this Prarabdha Karma. Hence, even at the time of birth, the fruits of actions which a person is supposed to face is already decided including the lifeline of a person. But, this is not static. This does not mean there is no role for free Will.
The fruits of Prarabdha Karmas manifest as various situations that a person faces, as various people that a person meets through rina, and as various mental impressions that govern one's decisions. But, inspite of all this, a person has a "Free-Will".
The exertion of free will is called "Agami Karma" and it may give fruit in this life itself or may be stored as Sanchita to give fruits in future lives.
Therefore, though, a general lifeline of a person is decided right at birth, by free will, a person can elongate or shorten it. Example, Markandeya had very short life, but his devotion to Shiva, which was exertion of free-will will, resulted in Shiva granting him immortality.
Similarly, a person who performs too much adharma and cause sorrow to others, may also have his life shortened.
Hope this helps.