Re: Wrapping Errors



On Thu, 20 Aug 2009 at 22:09:21 -0400, Yu Feng wrote:
> However, because
> GError is always accessed by pointers and no GLib program is supposed to
> statically allocate memory for GError

Er, is nobody supposed to allocate GErrors statically? That's the first I'd
heard of it...

In code using dbus-glib to implement async methods, it's very convenient to
do things like this:

if (!check_permission(...))
  {
    GError e = { TP_ERRORS, TP_ERROR_PERMISSION_DENIED,
        "no you can't have a pony" };

    dbus_g_method_return_error (context, &e);
  }

to avoid a pointless allocate/free when using functions like
dbus_g_method_return_error (or g_error_copy), which take a const error...
is this forbidden, and if so, by what?

    Simon


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