ANSWER:
When a person does shirk or kufr, all of his good deeds are erased. If he dies without reverting to Islam and repenting, he will abide in hell for eternity.
If he repents and accepts Islam before he dies, all of his good deeds would be restored.