Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Fwd: Re: Re: Request (PR#939)
Home

[Freeciv-Dev] Re: Fwd: Re: Re: Request (PR#939)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Paul Zastoupil <paulz@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Fwd: Re: Re: Request (PR#939)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 6 Sep 2001 09:35:08 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Sep 05, 2001 at 03:01:42PM -0700, Paul Zastoupil wrote:
>  /**************************************************************************
> @@ -184,6 +185,7 @@
>  {
>    int out_only[] = {E_IMP_BUY, E_IMP_SOLD, E_UNIT_BUY, E_MY_DIPLOMAT,
>                  E_UNIT_LOST_ATT, E_UNIT_WIN_ATT};
> +  int all[] = {E_MESSAGE_WALL};
>    int i;
>  
>    for(i=0; i<E_LAST; i++) {
> @@ -191,6 +193,9 @@
>    }
>    for(i=0; i<sizeof(out_only)/sizeof(int); i++) {
>      messages_where[out_only[i]] = MW_OUTPUT;
> +  }
> +  for(i=0; i<sizeof(all)/sizeof(int); i++) {

A general macro for this?
$ grep -Ir "sizeof.*/.*sizeof" .|wc -l
     30

Sugestions:
./linux/ftape.h:#define NR_ITEMS(x)     (int)(sizeof(x)/ sizeof(*x))
./linux/kernel.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./mysql/my_global.h:#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
./sp/include/macros.h:#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
./pgsql/c.h:#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))

> +  char wallbuffer[2048];
> +  wallbuffer[0]=0;
> +  cat_snprintf(wallbuffer, sizeof(wallbuffer),"%s",str);

What about strncpy? printf seems like overkill here.

Otherwise it looks fine.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  +#if defined(__alpha__) && defined(CONFIG_PCI)
  +       /*
  +        * The meaning of life, the universe, and everything. Plus
  +        * this makes the year come out right.
  +        */
  +       year -= 42;
  +#endif
    -- Patch for 1.3.2 (kernel/time.c) from Marcus Meissner


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