Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] Re: (PR#12893) [PATCH] improved hash tables
Home

[Freeciv-Dev] Re: (PR#12893) [PATCH] improved hash tables

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vasc@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12893) [PATCH] improved hash tables
From: "Benoit Hudson" <bh@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Apr 2005 09:53:08 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12893 >

On Tue, Apr 26, 2005 at 05:51:50AM -0700, Vasco Alexandre da Silva Costa wrote:
> I could probably live without the free functions for the scripting
> engine, since I now have hash_lookup. But the free functions are more
> efficient and can make the userland code simpler in other cases.

Great!  Every time I use a hash I want to have free functions.

Comments: 

(1) hash_free should check h->free_key_fun and h->free_data_func once
before the loop; only loop if one of them is non-null.

(2) breaking constness (data and key are const; but to free them we need
to remove the const quals) is unfortunate; I'm not sure what the most
elegant solution is.  This isn't a new problem: hash_replace and
hash_lookup_data return void* rather than const void*.

        -- Benoît





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