refs: manage lifetime of packed refs cache via reference counting
commit5f5e2a8868e2b5792bf467799339e3288282e91e
authorMichael Haggerty <mhagger@alum.mit.edu>
Thu, 20 Jun 2013 08:37:47 +0000 (20 10:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2013 22:50:17 +0000 (20 15:50 -0700)
tree7bd4d9e06957d9ab93ba705e698fb15119f0ca60
parent9f69d297703bff37c5506276c2565c721347e03f
refs: manage lifetime of packed refs cache via reference counting

In struct packed_ref_cache, keep a count of the number of users of the
data structure.  Only free the packed ref cache when the reference
count goes to zero rather than when the packed ref cache is cleared.
This mechanism will be used to prevent the cache data structure from
being freed while it is being iterated over.

So far, only the reference in struct ref_cache::packed is counted;
other users will be adjusted in separate commits.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c