Fwd: Re: PATCH: anti memleak part 2 [ali akcaagac stud fh-wilhelmshaven de]
- From: Ali Akcaagac <ali akcaagac stud fh-wilhelmshaven de>
- To: balsa-list gnome org
- Subject: Fwd: Re: PATCH: anti memleak part 2 [ali.akcaagac@stud.fh-wilhelmshaven.de]
- Date: Thu, 18 Oct 2001 19:10:18 +0200
On 2001.10.18 18:41:47 +0200 Peter Bloomfield wrote:
> > - count=d_get_gint("MRUCount", 0);
> > - for(i=0;i<count;i++) {
> > - sprintf(tmpkey, "MRU%d", i+1);
> > - (*mru)=g_list_append((*mru), gnome_config_get_string(tmpkey));
> > + count = d_get_gint("MRUCount", 0);
> > + for (i = 0; i < count; i++) {
> > + tmpkey = g_strdup_printf("MRU%d", i + 1);
> > + (*mru) = g_list_append((*mru), gnome_config_get_string(tmpkey));
> > + g_free (tmpkey);
> > }
> > }
>
> While you're changing this...wouldn't it be cleaner to code this as
>
> static GList *
> load_mru(GList *mru)
> {
> int i;
>
> for (i = d_get_gint("MRUCount", 0); i > 0; --i) {
> gchar *tmpkey = g_strdup_printf("MRU%d", i);
> mru = g_list_prepend(mru, gnome_config_get_string(tmpkey));
> g_free(tmpkey);
> }
>
> return mru;
> }
>
> and call it with `balsa_app.folder_mru =
> load_mru(balsa_app.folder_mru);'?
probably, i just went through the code as is and did quick changes.
thats why you still need to correct me sometimes. :)
> > @@ -1089,19 +1084,18 @@
> > gboolean correct;
> > gchar *word = NULL;
> >
> > -
> > word = gtk_editable_get_chars(GTK_EDITABLE(spell_check->text),
> > spell_check->start_pos,
> > spell_check->end_pos);
> >
> > if (word) {
> > -
> > if (balsa_app.debug)
> > balsa_information(LIBBALSA_INFORMATION_DEBUG,
> > "BalsaSpellCheck: Check %s", word);
> >
> > correct = pspell_manager_check(spell_check->spell_manager,
> > word);
> > } else {
> > + g_free(word);
> > return TRUE;
> > }
>
> I don't believe this one's necessary: you get to the new `g_free(word)'
> only on the `else' clause of `if (word)'--so it would always be the
> same as `g_free(NULL)', i.e. a no-op.
depends, i belive it is, since you see above that word is beeing
assigned to an address, now if word is not NULL means an address
is assigned then i need to free it in the else clause.. if i am right.
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@stud.fh-wilhelmshaven.de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]