lib: bt_object_{get,put}_ref(): accept a `const` parameter
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 3 Dec 2018 21:43:05 +0000 (16:43 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
commit398454ed067b95215c7affbe265fd36edab931ee
treed6853c2966265a11aaaf5a738817b81bebe4d70c
parente1e02a22957d83adc526c016d5d3b978b8e6d26d
lib: bt_object_{get,put}_ref(): accept a `const` parameter

This is the first step to make the whole API const-correct.
bt_object_get_ref() and bt_object_put_ref() are not considered to
logically modify the object: they change the reference count, but the
object's readable properties remain unchanged. Considering this, it is
simpler to have a single version of each of them accepting a const
object so as to be able to get and put const objects (eventually).

bt_object_put_ref() can have the effect of destroying/freeing the
object, just like Linux's kfree() does while accepting a `const void *`
parameter.

It is safe to cast away `const` in this library because the user only
passes opaque handles to functions (`struct bt_X *` types) pointing to
non-const objects defined by the library itself in writable memory
(usually through g_new0()).

In C++11, the equivalent of having a `const struct bt_X *` object on
which you can increment and decrement the reference count would be
having an `std::shared_ptr<const bt_X>` object: the wrapper is mutable,
but the contained object is const.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
29 files changed:
cli/babeltrace-cfg-cli-args-connect.c
cli/babeltrace-cfg-cli-args.c
cli/babeltrace-cfg.h
cli/babeltrace.c
include/babeltrace/object-internal.h
include/babeltrace/object.h
include/babeltrace/plugin/plugin-internal.h
lib/graph/component-class-sink-colander.c
lib/graph/component.c
lib/graph/iterator.c
lib/graph/notification/stream.c
lib/object.c
lib/plugin/plugin-so.c
lib/plugin/plugin.c
lib/trace-ir/clock-value.c
lib/trace-ir/event-class.c
lib/trace-ir/field-classes.c
lib/trace-ir/fields.c
lib/trace-ir/packet.c
lib/trace-ir/stream-class.c
lib/trace-ir/trace.c
plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c
plugins/ctf/common/metadata/ctf-meta.h
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/fs.c
plugins/utils/muxer/muxer.c
tests/lib/test_trace_ir_ref.c
This page took 0.027475 seconds and 4 git commands to generate.