daf bit: Shekalim 19
In the temple there were chests for money designated for different purposes. The mishna discusses cases where a coin is found (for example, on the floor) between two of the chests: what do we do with it? The mishna describes several examples; in all of them the coin is assigned to the nearer chest, even if that means assigning it to a less-important (less-holy) purpose. But if the coin is found half-way between two chests, it is assigned to the purpose that is more important. Specifically: freewill-offerings trump shekels, frankincense trumps wood, young pigeons for burnt-offerings trump bird-offerings, and second tithes trump common money. (19a)
The temple didn't keep one mingled collection of money and a ledger; when money was set aside for a purpose, that specific money was used. I don't know how much this is error-avoidance (you can't mess up the accounting) and how much is that money designated for a holy purpose "attaches" to that holy purpose. The latter is definitely a factor; I just don't know if it's the only factor. (This is a consideration today too).