Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: GTK+ client memory leaks
Home

[Freeciv-Dev] Re: GTK+ client memory leaks

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: GTK+ client memory leaks
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Thu, 28 Nov 2002 08:43:10 +0100

On Thu, Nov 28, 2002 at 12:25:23AM +0000, Vasco Alexandre Da Silva Costa wrote:
> On Wed, 27 Nov 2002, Raimar Falke wrote:
> > On Wed, Nov 27, 2002 at 01:59:14AM +0000, Vasco Alexandre Da Silva Costa 
> > wrote:
> > >
> > > Howdy,
> > >
> > > I found a whole heap of memory leaks in the GTK+ client produced by
> > > spurious use of the intl_slist() function and "forgetting" to free the
> > > memory afterwards. This affects the city dialog and a bunch of other 
> > > places.
> > >
> > > Such mallocing is unwarranted in the first place so I recomend we replace
> > > that most troublesome function with this one:
> > >
> > > void intl_slist(int n, const char **s, bool *done)
> > > {
> > >   int i;
> > >
> > >   if (!*done) {
> > >     for(i=0; i<n; i++) {
> > >       s[i] = _(s[i]);
> >
> > There is no guarantee that strlen(_(s[i])) <= strlen(s[i]).
> 
> That is utterly irrelevant. Look again at what I am passing to the 2nd
> argument of this function (i.e. const char **s):
> 
> static gchar *title[4] =
>       { N_("Type"), N_("Info"), N_("Cost"), N_("Turns") };
> 
> Hint: I am merely assigning a pointer not copying a string's contents.

I see. I'm asking myself why did we copyied the string before if it
can be with it?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 1 + 1 = 3, for large values of 1


[Prev in Thread] Current Thread [Next in Thread]