Make g_clear_pointer() more type safe
When doing some bug hunting in Builder, I found a handful of errors where we were using an incorrect free function with
g_clear_pointer(). For example, a
GPtrArray matched with
g_ptr_array_free(). This obviously has a disastrous effect, likely heap corruption.
We don't currently warn on this type of code because of the
g_clear_pointer() macro which loses the type precision of the
GDestroyNotify compatible callback.
Given the number of bugs I found in the Builder and Dazzle code-base, I'm quite certain bugs exist elsewhere in our usage. We should probably consider changing the macro to preserve the parameter types if at all possible.
There is some risk that doing so could break existing code (especially if
-Werror), but perhaps we can guard that with a macro check for
I have a naive version in Dazzle that I'm using in the mean time.