daf bit: Shekalim 6
The talmud discusses money that is collected for communal purposes (like the half-shekel temple tax for which the tractate is named). What happens if you accidentally set aside too much money for a designated purpose? It depends on what the purpose was. Excess shekalim go to the common treasury. Excess money for sin-offerings or guilt-offerings are set aside for freewill-offerings. Some types of designated monies must be used for another case of the same type of offering: excess for a burnt-offering is used for (another) burnt-offering, and likewise for meal-offerings, peace-offerings, Pesach-offerings, and Nazarites (in general). (Money for a specific Nazarite's offering goes to freewill-offerings.)
We then get a long list of cases following a common pattern: money raised for the poor must be spent on other poor, but money raised for a particular poor man must be given to him; money for ransoming captives must be spent on other captives, but excess money for a particular captive is given to him; money for burial of the dead is used for other dead, but excess money for burial of a particular person is given to his heirs. R. Meir says in this last case the money is held until Eliyahu comes (Eliyahu will sort out all unanswered questions), while R. Nathan says it must be used to raise a monument over his grave. (Mishna 2.5, daf 6b)