Re: [evolution-patches] Memory leaks; shell part
- From: Hans Petter Jansson <hpj ximian com>
- To: Ettore Perazzoli <ettore ximian com>
- Cc: evolution-patches ximian com
- Subject: Re: [evolution-patches] Memory leaks; shell part
- Date: 15 Apr 2003 12:52:40 -0500
On Tue, 2003-04-15 at 11:40, Ettore Perazzoli wrote:
> RCS file: /cvs/gnome/evolution/shell/e-setup.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 e-setup.c
> --- e-setup.c 8 Apr 2003 16:05:35 -0000 1.38
> +++ e-setup.c 15 Apr 2003 03:10:17 -0000
> @@ -303,11 +303,18 @@ e_setup_check_config (const char *evolut
> {
> GConfClient *client;
> char *tmp;
> + gboolean present = FALSE;
>
> client = gconf_client_get_default ();
>
> tmp = gconf_client_get_string (client,
> "/apps/evolution/shell/default_folders/mail_uri", NULL);
> - if (tmp != NULL && *tmp != 0) {
> + if (tmp != NULL) {
> + if (*tmp != 0)
> + present = TRUE;
> + g_free (tmp);
> + }
> +
> + if (present) {
> g_object_unref (client);
> return;
> }
>
> Hmm I don't understand what "present" is for here, but the freeing of
> "tmp" itself looks good.
It's just so I don't have to free tmp on both branches of the test. I
usually prefer to allocate, test, free, then branch on the test result,
instead of allocate, test, branch, free on both branches.
I can put in two g_free (tmp) there instead of an extra variable, if you
think it'll look nicer.
(I picked the variable name "present" to mean "mail_uri_is_present").
--
Hans Petter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]