Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations
Home

[Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bh@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Thu, 29 Jan 2004 01:12:54 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >

On Wed, Jan 28, 2004 at 07:12:17PM -0800, Benoit Hudson wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >
> 
> Right, and here's the promised patch.

What about runtime impact?

Can't MAX_COMBINATIONS be removed then?

> +#if SHOW_CM_STORAGE_USED
> +static void report_cm_storage_used(void)
> +{
> +  int i, sum=0;
> +  for(i=0; i<=MAX_FIELDS_USED; ++i) {
> +    sum += cache3.results[i].ncombinations_allocated
> +      * sizeof(struct combination*);
> +    sum += cache3.results[i].ncombinations
> +      * sizeof(struct combination);
> +  }
> +  sum += sizeof(cache3);
> +  freelog(LOG_NORMAL, "CM: cache3 uses %d bytes", sum);
> +  /* we should compute the cache1 and cache2 usage as well. */
> +}
> +#endif

> +#if SHOW_CM_STORAGE_USED
> +  report_cm_storage_used();
> +#endif

If you move the #if inside the function you only have the #if one
time. IMHO better even if you call an empty function.

Overall it looks good. I know that CM uses a big amount of memory. I
just wasn't motivated to make it dynamic at this time.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  This message has been ROT-13 encrypted twice for extra security.




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