Web lists-archives.com

Re: g_error_free() warning on null pointer




But if you have an error, shouldn't you either want to a) handle it,
or b) propagate it up?

I can't imagine a case where you want to free a GError without first
attempting to handle it. If you do want to ignore errors, you can
simply pass NULL for a GError ** pointer to a function, since those
should always handle NULL correctly.

On Sat, Aug 29, 2015 at 11:13 AM, Michael McConville
<mmcconv1@xxxxxxxxxxxxxxxxxxx> wrote:
> Nicolas George wrote:
>> But maybe I am forgetting another case: can you imagine a code snippet
>> where g_error_free(error) would make sense with error == NULL?
>
> I may have already mentioned this, but the simplest example is just
> adding a g_error_free() at the end of a function when adding a GError*
> declaration at the beginning. This prevents an irrelevant line from
> cluttering the error-handling logic and makes it more trivially obvious
> to auditors that there isn't a memory leak.
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list@xxxxxxxxx
> https://mail.gnome.org/mailman/listinfo/gtk-devel-list



-- 
  Jasper
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list