From 038be9903108fbf49bef18e6f6bd6936e8fabde8 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 3 Apr 2019 12:08:11 -0400 Subject: [PATCH] lib: Make bt_value_null a const pointer We probably don't want anything to change the value of this pointer, which points to the only instance of BT_VALUE_TYPE_NULL, bt_value_null_instance. Therefore, declare it as a constant value. It also helps a little bit the Python bindings: if we copy the declaration verbatim to the .i file, without const, bt_value_null is available through the special "cvar" global object (and can be modified!). With const, it becomes read-only, so can be accessed directly as native_bt.value_null. Signed-off-by: Simon Marchi --- include/babeltrace/value.h | 2 +- lib/value.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/babeltrace/value.h b/include/babeltrace/value.h index 1e6bdc47..89c4c64e 100644 --- a/include/babeltrace/value.h +++ b/include/babeltrace/value.h @@ -36,7 +36,7 @@ extern "C" { #endif -extern bt_value *bt_value_null; +extern bt_value *const bt_value_null; extern bt_value *bt_value_bool_create(void); diff --git a/lib/value.c b/lib/value.c index eb78ca9e..83168e74 100644 --- a/lib/value.c +++ b/lib/value.c @@ -87,7 +87,7 @@ struct bt_value bt_value_null_instance = { .frozen = BT_TRUE, }; -struct bt_value *bt_value_null = &bt_value_null_instance; +struct bt_value *const bt_value_null = &bt_value_null_instance; struct bt_value_bool { struct bt_value base; -- 2.34.1