Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: newbie C question
Home

[Freeciv-Dev] Re: newbie C question

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: newbie C question
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Mar 2002 14:48:07 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Mar 05, 2002 at 02:07:25PM +0100, Per I. Mathisen wrote:
> On Tue, 5 Mar 2002, Raimar Falke wrote:
> >        [#10] If an object that has automatic  storage  duration  is
> >        not  initialized explicitly, its value is indeterminate.  If
> >        an  object  that  has  static  storage   duration   is   not
> >        initialized explicitly, then:
> >
> >           - if it has pointer type, it is  initialized  to  a  null
> >             pointer;
> 
> So,
>    b = &improvement_types[i];
>    b->terr_gate = fc_realloc((count + 1) * sizeof(b->terr_gate[0]));
> 
> will work, since
>    struct impr_type improvement_types[B_LAST];
> 
> is a global and b->terr_gate is initialized to NULL? That will solve most
> of the reloading problems in server/ruleset.c

Yes.

> But only until we drop the assumption that the number of buildings is
> constant and we malloc() improvements_types too...

Yes. However the malloced structs have to initialized in this case anyway.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "The BeOS takes the best features from the major operating systems. 
  It's got the power and flexibility of Unix, the interface and ease 
  of use of the MacOS, and Minesweeper from Windows."


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