diff mbox

[07/10] tcg: Register the helper info struct rather than the name

Message ID 1399938424-6703-8-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson May 12, 2014, 11:47 p.m. UTC
This will let us find all the info from the hash table.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tcg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Alex Bennée May 13, 2014, 9:36 a.m. UTC | #1
Richard Henderson <rth@twiddle.net> writes:

> This will let us find all the info from the hash table.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  tcg/tcg.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index b64471f..3bbf982 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -356,7 +356,7 @@ void tcg_context_init(TCGContext *s)
>  
>      for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
>          g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
> -                            (gpointer)all_helpers[i].name);
> +                            (gpointer)&all_helpers[i]);
>      }
>  
>      tcg_target_init(s);
> @@ -1149,7 +1149,10 @@ static inline const char *tcg_find_helper(TCGContext *s, uintptr_t val)
>  {
>      const char *ret = NULL;
>      if (s->helpers) {
> -        ret = g_hash_table_lookup(s->helpers, (gpointer)val);
> +        TCGHelperInfo *info = g_hash_table_lookup(s->helpers, (gpointer)val);
> +        if (info) {
> +            ret = info->name;
> +        }
>      }
>      return ret;
>  }
diff mbox

Patch

diff --git a/tcg/tcg.c b/tcg/tcg.c
index b64471f..3bbf982 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -356,7 +356,7 @@  void tcg_context_init(TCGContext *s)
 
     for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
         g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
-                            (gpointer)all_helpers[i].name);
+                            (gpointer)&all_helpers[i]);
     }
 
     tcg_target_init(s);
@@ -1149,7 +1149,10 @@  static inline const char *tcg_find_helper(TCGContext *s, uintptr_t val)
 {
     const char *ret = NULL;
     if (s->helpers) {
-        ret = g_hash_table_lookup(s->helpers, (gpointer)val);
+        TCGHelperInfo *info = g_hash_table_lookup(s->helpers, (gpointer)val);
+        if (info) {
+            ret = info->name;
+        }
     }
     return ret;
 }