[Freeciv-Dev] Re: newbie C question
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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."
- [Freeciv-Dev] Re: newbie C question, (continued)
[Freeciv-Dev] Re: newbie C question, Jules Bean, 2002/03/05
[Freeciv-Dev] Re: newbie C question, Piotr Sulecki, 2002/03/05
[Freeciv-Dev] Re: newbie C question, Reinier Post, 2002/03/06
[Freeciv-Dev] Re: newbie C question, Raimar Falke, 2002/03/05
|
|