Skip to content

gmem.h: Use __typeof__() in the g_clear_pointer() macro

Iain Lane requested to merge type-safe-g-clear-pointer-1425 into master

Type punning is used on the existing implementation, which hides errors such as:

GSList *list = NULL; g_clear_pointer (&list, g_error_free);

Let's use typeof to cast the passed-in pointer before it's passed to the free function so it trips -Wincompatible-pointer-types if it's wrong.

Fixes #1425 (closed)

Merge request reports