[Mesa-dev] [PATCH 1/2] hash_table: Make string_to_uint_map make a copy of the name
Luzipher McLeod
luziphermcleod at yahoo.ie
Sat Oct 8 06:26:44 PDT 2011
Hi all :-)
first, I'm not really sure how to handle mailing list ... I hope "Reply All" was the right button.
This patch solves the texture problems for me (Bug 41499). Thanks :-)
Regards,
Luzipher
--- On Sat, 8/10/11, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <idr at freedesktop.org>
> Subject: [PATCH 1/2] hash_table: Make string_to_uint_map make a copy of the name
> To: mesa-dev at lists.freedesktop.org
> Cc: "Ian Romanick" <ian.d.romanick at intel.com>, "Stéphane Marchesin" <stephane.marchesin at gmail.com>, "Luzipher" <luziphermcleod at yahoo.ie>, "Michał Lipski" <tallica at o2.pl>
> Date: Saturday, 8 October, 2011, 0:33
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> The hash table needs a copy of the key that it can keep
> for
> comparisons during searches.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41499
> Cc: Stéphane Marchesin <stephane.marchesin at gmail.com>
> Cc: Luzipher <luziphermcleod at yahoo.ie>
> Cc: Michał Lipski <tallica at o2.pl>
> ---
> src/mesa/program/hash_table.h | 18
> +++++++++++++++++-
> 1 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/program/hash_table.h
> b/src/mesa/program/hash_table.h
> index bfe221b..941d28a 100644
> --- a/src/mesa/program/hash_table.h
> +++ b/src/mesa/program/hash_table.h
> @@ -32,6 +32,7 @@
> #define HASH_TABLE_H
>
> #include <string.h>
> +#include <stdlib.h>
> #include <stdint.h>
> #include <limits.h>
> #include <assert.h>
> @@ -100,6 +101,10 @@ extern void *hash_table_find(struct
> hash_table *ht, const void *key);
> * calls to \c hash_table_find and \c
> hash_table_remove will return or remove,
> * repsectively, the most recently added instance of
> \c key.
> *
> + * \warning
> + * The value passed by \c key is kept in the hash table
> and is used by later
> + * calls to \c hash_table_find.
> + *
> * \sa hash_table_replace
> */
> extern void hash_table_insert(struct hash_table *ht, void
> *data,
> @@ -204,6 +209,7 @@ public:
>
> ~string_to_uint_map()
> {
> + hash_table_call_foreach(this->ht,
> delete_key, NULL);
>
> hash_table_dtor(this->ht);
> }
>
> @@ -243,10 +249,20 @@ public:
> * because UINT_MAX+1 = 0.
> */
> assert(value != UINT_MAX);
> - hash_table_replace(ht, (void *)
> (intptr_t) (value + 1), key);
> + hash_table_replace(this->ht,
> +
> (void *) (intptr_t) (value +
> 1),
> +
> strdup(key));
> }
>
> private:
> + static void delete_key(const void *key,
> void *data, void *closure)
> + {
> + (void) data;
> + (void) closure;
> +
> + free((char *)key);
> + }
> +
> struct hash_table *ht;
> };
>
> --
> 1.7.6
>
>
More information about the mesa-dev
mailing list