On Jan 22, 2021, at 11:30 AM, Laine Stump <laine(a)redhat.com>
wrote:
On 1/22/21 11:05 AM, Laine Stump wrote:
> 1) There are several cleanup functions in external libraries that in the past were
only called after checking that the pointer was != NULL. g_autoptr cleanups need to handle
being called with NULL as a NOP, and I'm concerned that these functions may not behave
properly in that case. Can you either verify that it's safe to call them with NULL, or
provide a wrapper function that checks for NULL and use that as the cleanup?
I asked about item (2) on IRC just now, and danpb produced a short example program that
proves it is okay to use values from auto-freed objects as the return value of a function.
So there is only question (1) left. Let me know and I'll either push or wait for
modified patches accordingly.
For WsXmlDocH, GLib's documentation says that
G_DEFINE_AUTOPTR_CLEANUP_FUNC() is NULL-safe:
The function will not be called if the variable to be cleaned up
contains NULL.
https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#G-...
For client_opt_t and filter_t, the third parameter to
G_DEFINE_AUTO_CLEANUP_FREE_FUNC() was used to prevent the types' free
functions from being called if they're NULL.
--
Matt