Re: GError update



On 26 Jun 2000, Havoc Pennington wrote:

> 
> OK, the latest iteration.

> typedef struct _GError GError;
> struct _GError
> {
>   GQuark       domain;
>   gint         code;
>   const gchar *message;
> };

> GError*  g_error_new           (GQuark         domain,
> GError*  g_error_new_literal   (GQuark         domain,
> void     g_error_free          (GError        *error);
> GError*  g_error_copy          (const GError  *error);
> gboolean g_error_matches       (const GError  *error,
> void     g_error_set           (GError       **err,
> void     g_error_clear         (GError       **err);


oh havoc. first you make me write a lengthy mail on the user_data
and allocation stuff, and now you get rid of only part of it without
giving reasoning.
what i see here is mostly picking worst behaviour of all the
different schemes we discussed.
you do skip user_data which gives you the opportunity to change
the allocation scheme and get rid of that GError** pointer, but
you don't.
having g_error_*() functions operate on GError* sometimes, and
operating on GError** other times simply is wrong. i couldn't
even tell what that's usefull for, for one, you could simply
provide:

void     g_error_set           (GError       **error,
                                ...);
void     g_error_clear         (GError       **error);
void     g_error_copy          (GError       **src_error,
                                GError       **dest_error);
gboolean g_error_match         (GError       **error,
                                ...);

and be just as powerfull with your API. but then i don't quite
understand why you need to have that extra pointer indirection
in the first place. if you let people set a GError** through your
API (g_error_set) and they need to sometimes assign GError* themselves
(g_error_new), i bet we'll leak some errors on the way when non-NULL
GError** are assigned.
(i did s/g_error_matches/g_error_match/ on the fly, since that's
the kind of naming we used for gtk_pattern_match() as well, though
i'd probably call that _test or _check since you don't do any kind
of complicated matching there).

---
ciaoTJ





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