fix marker hash with array
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Oct 2007 21:52:04 +0000 (21:52 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Oct 2007 21:52:04 +0000 (21:52 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2701 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/marker.c
ltt/branches/poly/ltt/marker.h

index 7b19391b0734baf67b6d2b0566ee5d0a5dfdb293..54209570f787c9fccbb72d3a1f46db95a5aaddf1 100644 (file)
@@ -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;
     }
   }
index fc1343567837de76837e08482051ff3e25c549f1..9a4f4144c127372844730df95e5c46d7ddacf975 100644 (file)
@@ -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,
This page took 0.025644 seconds and 4 git commands to generate.