1
0
forked from 0ad/0ad

fix 2 stupid h_mgr_shutdown bugs leading to failure to close some leaked handles at exit (see bug 26)

- was iterating over all HDATA slots up to last_in_use, but it is
inclusive
- when closing, wasn't resetting refcount, so h_free kept those with
refcount > 1 open

This was SVN commit r1158.
This commit is contained in:
janwas 2004-09-19 13:46:38 +00:00
parent a872461a47
commit b3a5bad377

View File

@ -249,11 +249,17 @@ static HDATA* h_data(const Handle h, const H_Type type)
void h_mgr_shutdown(void)
{
// close open handles
for(i32 i = 0; i < last_in_use; i++)
for(i32 i = 0; i <= last_in_use; i++)
{
HDATA* hd = h_data(i);
if(hd)
// can't fail - i is in bounds by definition, and
// each HDATA entry has already been allocated.
if(!hd)
{
debug_warn("h_mgr_shutdown: h_data failed - why?!");
continue;
}
// it's already been freed; don't free again so that this
// doesn't look like an error.
if(!hd->tag)
@ -265,10 +271,10 @@ void h_mgr_shutdown(void)
// disable caching; we need to release the resource now.
hd->keep_open = 0;
hd->refs = 0;
h_free(h, hd->type);
}
}
// free HDATA array
for(uint j = 0; j < num_pages; j++)