Fix: --clock-force-correlate to handle trace collections gathered from various nodes
[babeltrace.git] / types / variant.c
index bb4faa17093a87ec0266f7f08349922037105e1b..faf70dde200e6bbff757ecc889e1132e5dca5cde 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <babeltrace/compiler.h>
 #include <babeltrace/format.h>
+#include <babeltrace/types.h>
 #include <errno.h>
 
 static
@@ -273,11 +274,18 @@ void untagged_variant_declaration_add_field(struct declaration_untagged_variant
 struct declaration_field *
 untagged_variant_declaration_get_field_from_tag(struct declaration_untagged_variant *untagged_variant_declaration, GQuark tag)
 {
-       unsigned long index;
+       gpointer index;
+       gboolean found;
 
-       index = (unsigned long) g_hash_table_lookup(untagged_variant_declaration->fields_by_tag,
-                                                   (gconstpointer) (unsigned long) tag);
-       return &g_array_index(untagged_variant_declaration->fields, struct declaration_field, index);
+       found = g_hash_table_lookup_extended(
+                               untagged_variant_declaration->fields_by_tag,
+                               (gconstpointer) (unsigned long) tag, NULL, &index);
+
+       if (!found) {
+               return NULL;
+       }
+
+       return &g_array_index(untagged_variant_declaration->fields, struct declaration_field, (unsigned long)index);
 }
 
 /*
This page took 0.022895 seconds and 4 git commands to generate.