[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]
<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.
|
|