GThread posix: add impl structs to cleanup list

There are two ways of using the structs like GMutex, GCond, etc.

The first is to explicitly _init() and _clear() them.  This is when you
use them as part of another structure.  This case is not interesting for
gcleanup.

The other is to have them in static storage (zero-filled) and just use
them for the first time.  This is the difficult case, because we don't
ever free the impl in that case.

In the first case, the impl is created and set in the _init() function.
We can therfore tell that we are in the second case if we get to the
get_impl() function and the impl is not there yet.  In that case, add it
to the cleanup list.

There are probably people that allocate a GMutex as part of a
zero-filled structure and use it, then call g_mutex_clear() on it.  This
is technically a violation of the API and these users will crash with
G_DEBUG=cleanup, but that's a good thing because it will cause them to
fix their code.
1 file changed