From abc34be778e8e109b372add89963e1a6651785b6 Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 15 Oct 2007 21:52:04 +0000 Subject: [PATCH] fix marker hash with array git-svn-id: http://ltt.polymtl.ca/svn@2701 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/marker.c | 13 ++++++++----- ltt/branches/poly/ltt/marker.h | 10 +++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ltt/branches/poly/ltt/marker.c b/ltt/branches/poly/ltt/marker.c index 7b19391b..54209570 100644 --- a/ltt/branches/poly/ltt/marker.c +++ b/ltt/branches/poly/ltt/marker.c @@ -406,7 +406,7 @@ int marker_format_event(LttTrace *trace, GQuark name, const char *format) { struct marker_info *info; - info = g_hash_table_lookup(trace->markers_hash, (gconstpointer)name); + info = marker_get_info_from_name(trace, name); if (!info) g_error("Got marker format \"%s\", but marker name \"%s\" has no ID yet. " "Kernel issue.", @@ -431,7 +431,8 @@ int marker_id_event(LttTrace *trace, GQuark name, guint16 id, int found = 0; if (trace->markers->len <= id) - trace->markers = g_array_set_size(trace->markers, id+1); + trace->markers = g_array_set_size(trace->markers, + max(trace->markers->len * 2, id + 1)); info = &g_array_index(trace->markers, struct marker_info, id); info->name = name; info->int_size = int_size; @@ -440,16 +441,18 @@ int marker_id_event(LttTrace *trace, GQuark name, guint16 id, info->size_t_size = size_t_size; info->alignment = alignment; info->next = NULL; - head = g_hash_table_lookup(trace->markers_hash, (gconstpointer)name); + head = marker_get_info_from_name(trace, name); if (!head) - g_hash_table_insert(trace->markers_hash, (gpointer)name, info); + g_hash_table_insert(trace->markers_hash, (gpointer)name, + (gpointer)(gulong)id); else { struct marker_info *iter; for (iter = head; iter != NULL; iter = iter->next) if (iter->name == name) found = 1; if (!found) { - g_hash_table_replace(trace->markers_hash, (gpointer)name, info); + g_hash_table_replace(trace->markers_hash, (gpointer)name, + (gpointer)(gulong)id); info->next = head; } } diff --git a/ltt/branches/poly/ltt/marker.h b/ltt/branches/poly/ltt/marker.h index fc134356..9a4f4144 100644 --- a/ltt/branches/poly/ltt/marker.h +++ b/ltt/branches/poly/ltt/marker.h @@ -63,7 +63,15 @@ static inline struct marker_info *marker_get_info_from_id(LttTrace *trace, static inline struct marker_info *marker_get_info_from_name(LttTrace *trace, GQuark name) { - return g_hash_table_lookup(trace->markers_hash, (gconstpointer)name); + gpointer orig_key, value; + guint16 id; + int res; + + res = g_hash_table_lookup_extended(trace->markers_hash, (gconstpointer)name, + &orig_key, &value); + if (!res) + return NULL; + return marker_get_info_from_id(trace, (guint16)(gulong)value); } static inline struct marker_field *marker_get_field(struct marker_info *info, -- 2.34.1