lib: Make bt_value_null a const pointer
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 3 Apr 2019 16:08:11 +0000 (12:08 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
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 <simon.marchi@efficios.com>
include/babeltrace/value.h
lib/value.c

index 1e6bdc47c468b9398a0870d5e05a4b64fab323b5..89c4c64ef5311ea8b874c2d1d977a0017801b129 100644 (file)
@@ -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);
 
index eb78ca9ecd10b5ba975ad0776c4d4b47b9a9f852..83168e74fe9cd99c22922342a219684865a31feb 100644 (file)
@@ -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;
This page took 0.025132 seconds and 4 git commands to generate.