active_cache leaks

From: Brad Roberts <hidden>
Date: 2016-06-15 22:41:52

Ok.. so there's been a couple attempts to patch the leak that were all
wrong due to mixed memory management for that array.  Here's a seed for
discussion on how to plug that leak.  Some would argue that it's not
leaking enough to fix, but for those that want to turn git into a library,
the lifetime of the cache could end up not being short any more, so it's
worth discussing how to fix it.

The q&d fix in this patch isn't elegant, but gets the job done.  More
interesting could be to have the entry itself contain a state bit, though
that wastes storage space.

Two basic changes:

1) introduce a set_active_cache() api and change all 'active_cache[i] = ce'
   calls to use it.
2) add a active_cache_malloced array to parallel the active_cache array.

I don't like #2, but see that q&d comment. :)

It's only lightly tested as I'm still trying to wrap my head around how to
actually use git and git-pasky.

I was tempted to add a get_cache_entry api as well, so that nothing
outside of read-cache.c touched active_cache directly, but that can come
next.

Later,
Brad

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help