Re: g_error_free() warning on null pointer



On Sat, 15 Aug 2015, Jasper St. Pierre wrote:

Lots of things in GLib fail when passed a NULL pointer, like g_object_unref.

The idea is that passing a NULL pointer is probably a sign of a bug
somewhere, so you shouldn't do it. [...]

On the one hand, the function is question is specialized, it's not free(), nor g_free(), and no standard mandates that it should accept a NULL pointer as a no-op.

On the other hand, if this function in fact accepts a NULL without error it's perverse that it should make a fuss about it. It seems to me that by far the most likely case of g_error_free() getting a NULL argument is a coder expecting NULL -> no-op semantics by analogy with C's free(). What sort of bug would you have in mind?

@McConville: the standard most relevant to your argument is the ISO C standard, not POSIX.

Allin Cottrell


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]