lib: fix compilation for glib < 2.40
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 27 Jun 2019 20:03:55 +0000 (16:03 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 19:38:29 +0000 (15:38 -0400)
Code from commit "lib: add logic in auto-seek to recreate stream state"
uses the return value of function g_hash_table_insert to validate that
the inserted key did not previously exist in the hash table.  This
feature was introduced in glib 2.40, before that the function returned
void.

To avoid breaking compatibility with glib < 2.40, we can do a lookup
before inserting to achieve the same result.

Change-Id: Ibd5f58fb6ab8f083a3152105db9e05522893132c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1560
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/graph/iterator.c

index a53a89d8f31e4c0628255a7450462f23c9b5c2c1..31c4ec3ffc24da8be54f30b8b25f96aa9a3d7bd6 100644 (file)
@@ -25,6 +25,7 @@
 #include "lib/logging.h"
 
 #include "compat/compiler.h"
+#include "compat/glib.h"
 #include "lib/trace-ir/clock-class.h"
 #include "lib/trace-ir/clock-snapshot.h"
 #include <babeltrace2/trace-ir/field.h>
@@ -1220,7 +1221,6 @@ skip_msg:
        {
                const struct bt_message_stream *stream_msg = (const void *) msg;
                struct auto_seek_stream_state *stream_state;
-               gboolean did_not_exist;
 
                /* Update stream's state: stream began. */
                stream_state = create_auto_seek_stream_state();
@@ -1230,8 +1230,9 @@ skip_msg:
                }
 
                stream_state->state = AUTO_SEEK_STREAM_STATE_STREAM_BEGAN;
-               did_not_exist = g_hash_table_insert(stream_states, stream_msg->stream, stream_state);
-               BT_ASSERT(did_not_exist);
+
+               BT_ASSERT(!bt_g_hash_table_contains(stream_states, stream_msg->stream));
+               g_hash_table_insert(stream_states, stream_msg->stream, stream_state);
                break;
        }
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
This page took 0.026388 seconds and 4 git commands to generate.