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>
#include "lib/logging.h"
#include "compat/compiler.h"
#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>
#include "lib/trace-ir/clock-class.h"
#include "lib/trace-ir/clock-snapshot.h"
#include <babeltrace2/trace-ir/field.h>
{
const struct bt_message_stream *stream_msg = (const void *) msg;
struct auto_seek_stream_state *stream_state;
{
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();
/* Update stream's state: stream began. */
stream_state = create_auto_seek_stream_state();
}
stream_state->state = AUTO_SEEK_STREAM_STATE_STREAM_BEGAN;
}
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:
break;
}
case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: