fix group.test leaks

This commit is contained in:
Enno Rehling 2016-09-08 17:40:17 +02:00
parent a281ace21b
commit d5261ab1da
2 changed files with 8 additions and 3 deletions

View File

@ -125,10 +125,14 @@ attrib_type at_group = { /* attribute for units assigned to a group */
void free_group(group * g)
{
int index = g->gid % GMAXHASH;
group **g_ptr = ghash + index;
while (*g_ptr && (*g_ptr)->gid != g->gid)
int index;
group **g_ptr;
assert(g);
index = g->gid % GMAXHASH;
g_ptr = ghash + index;
while (*g_ptr && (*g_ptr)->gid != g->gid) {
g_ptr = &(*g_ptr)->nexthash;
}
assert(*g_ptr == g);
*g_ptr = g->nexthash;

View File

@ -91,6 +91,7 @@ static void test_group_readwrite(CuTest * tc)
write_groups(&store, f);
WRITE_INT(&store, 47);
free_group(f->groups);
free_group(g);
f->groups = 0;
data.strm.api->rewind(data.strm.handle);