Fix: freeze field type unconditionally
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Jun 2018 20:00:21 +0000 (16:00 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
Issue
=====
Field types should always be frozen (in both developer or production
modes) because they are metadata objects. Currently, they are only
frozen in developer mode.

Solution
========
Make the bt_field_type_common_freeze() and bt_field_type_freeze()
functions always called, not through a macro which is only enabled in
developer mode.

Known drawbacks
===============
Very small performance impact because we're trying to freeze a field
type every time bt_field_create() is called, but bt_field_create() is
not called often anyway due to field object pooling. The impact could
become noticeable eventually if we limit the sizes of object pools.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/ctf-ir/field-types-internal.h
lib/ctf-ir/field-types.c

index a15b9c0a13e5e62b283c1d4ab8f723b90b034e69..3940b1d49b53fcfd220ba467038757a652f2ccbf 100644 (file)
@@ -274,14 +274,6 @@ struct bt_field_type_common_string {
        enum bt_string_encoding encoding;
 };
 
-#ifdef BT_DEV_MODE
-# define bt_field_type_freeze          _bt_field_type_freeze
-# define bt_field_type_common_freeze   _bt_field_type_common_freeze
-#else
-# define bt_field_type_freeze(_ft)
-# define bt_field_type_common_freeze(_ft)
-#endif
-
 typedef struct bt_field_common *(* bt_field_common_create_func)(
                struct bt_field_type_common *);
 
@@ -620,10 +612,10 @@ enum bt_field_type_id bt_field_type_common_get_type_id(
                struct bt_field_type_common *ft);
 
 BT_HIDDEN
-void _bt_field_type_common_freeze(struct bt_field_type_common *ft);
+void bt_field_type_common_freeze(struct bt_field_type_common *ft);
 
 BT_HIDDEN
-void _bt_field_type_freeze(struct bt_field_type *ft);
+void bt_field_type_freeze(struct bt_field_type *ft);
 
 BT_HIDDEN
 struct bt_field_type_common *
index 11764121f76f6274996148d20ad4284f59be005a..a8a41b572488947d1668967cbe797db466ae75c6 100644 (file)
@@ -3431,7 +3431,7 @@ int bt_field_type_is_variant(struct bt_field_type *type)
 }
 
 BT_HIDDEN
-void _bt_field_type_common_freeze(struct bt_field_type_common *ft)
+void bt_field_type_common_freeze(struct bt_field_type_common *ft)
 {
        if (!ft || ft->frozen) {
                return;
@@ -3442,9 +3442,9 @@ void _bt_field_type_common_freeze(struct bt_field_type_common *ft)
 }
 
 BT_HIDDEN
-void _bt_field_type_freeze(struct bt_field_type *ft)
+void bt_field_type_freeze(struct bt_field_type *ft)
 {
-       _bt_field_type_common_freeze((void *) ft);
+       bt_field_type_common_freeze((void *) ft);
 }
 
 BT_HIDDEN
This page took 0.026658 seconds and 4 git commands to generate.