Fix: bt_event_common_initialize(): use appropriate callback types
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 5 Jun 2018 21:52:19 +0000 (17:52 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/ctf-ir/event-internal.h
lib/ctf-ir/event.c
lib/ctf-writer/event.c

index dccc5726f3a84e52d49dfd0e51bb3f0522654ad5..43a77a23069ef92a115e2f954303cb33b3de2911 100644 (file)
@@ -92,6 +92,11 @@ struct bt_event_class_common *bt_event_common_borrow_class(
        return event->class;
 }
 
+typedef void *(*create_field_func)(void *);
+typedef void (*release_field_func)(void *);
+typedef void *(*create_header_field_func)(void *, void *);
+typedef void (*release_header_field_func)(void *, void *);
+
 BT_HIDDEN
 int bt_event_common_initialize(struct bt_event_common *event,
                struct bt_event_class_common *event_class,
@@ -102,10 +107,10 @@ int bt_event_common_initialize(struct bt_event_common *event,
                int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
                        struct bt_field_type_common *packet_context_field_type,
                        struct bt_field_type_common *event_header_field_type),
-               void *(*create_field_func)(void *),
-               void (*release_field_func)(void *),
-               void *(*create_header_field_func)(void *, void *),
-               void (*release_header_field_func)(void *));
+               create_field_func create_field_func,
+               release_field_func release_field_func,
+               create_header_field_func create_header_field_func,
+               release_header_field_func release_header_field_func);
 
 static inline
 struct bt_field_common *bt_event_common_borrow_payload(
index 5cfd5e14a124515e8bbcfc943722c71c8b75e005..95a17d3a8ca4c0d9e9bf8713ce60b30337cd081e 100644 (file)
@@ -137,10 +137,10 @@ static
 int bt_event_common_create_fields(
                struct bt_stream_class_common *stream_class,
                struct bt_validation_output *validation_output,
-               void *(*create_field_func)(void *),
-               void (*release_field_func)(void *),
-               void *(*create_header_field_func)(void *, void *),
-               void (*release_header_field_func)(void *),
+               create_field_func create_field_func,
+               release_field_func release_field_func,
+               create_header_field_func create_header_field_func,
+               release_header_field_func release_header_field_func,
                struct bt_field_wrapper **header_field,
                struct bt_field_common **stream_event_context_field,
                struct bt_field_common **context_field,
@@ -197,7 +197,7 @@ int bt_event_common_create_fields(
 
 error:
        if (*header_field) {
-               release_header_field_func(*header_field);
+               release_header_field_func(*header_field, stream_class);
        }
 
        if (*stream_event_context_field) {
@@ -326,10 +326,10 @@ int bt_event_common_initialize(struct bt_event_common *event,
                int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
                        struct bt_field_type_common *packet_context_field_type,
                        struct bt_field_type_common *event_header_field_type),
-               void *(*create_field_func)(void *),
-               void (*release_field_func)(void *),
-               void *(*create_header_field_func)(void *, void *),
-               void (*release_header_field_func)(void *))
+               create_field_func create_field_func,
+               release_field_func release_field_func,
+               create_header_field_func create_header_field_func,
+               release_header_field_func release_header_field_func)
 {
        int ret;
        struct bt_trace_common *trace = NULL;
@@ -499,7 +499,7 @@ error:
        bt_put(expected_clock_class);
 
        if (event_header) {
-               release_header_field_func(event_header);
+               release_header_field_func(event_header, stream_class);
        }
 
        if (stream_event_context) {
@@ -575,10 +575,10 @@ struct bt_event *bt_event_new(struct bt_event_class *event_class)
                BT_TO_COMMON(event_class), NULL, NULL,
                (bt_validation_flag_copy_field_type_func) bt_field_type_copy,
                true, NULL,
-               (void *) bt_field_create_recursive,
-               (void *) bt_field_destroy_recursive,
-               (void *) create_event_header_field,
-               (void *) bt_event_header_field_recycle);
+               (create_field_func) bt_field_create_recursive,
+               (release_field_func) bt_field_destroy_recursive,
+               (create_header_field_func) create_event_header_field,
+               (release_header_field_func) bt_event_header_field_recycle);
        if (ret) {
                /* bt_event_common_initialize() logs errors */
                goto error;
index 2e94fe5550eb846da7fc1c63417653c4bc976112..447571c4d67bb88d4f0db9712f0d39a5a42654c7 100644 (file)
@@ -132,10 +132,10 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class)
                (bt_validation_flag_copy_field_type_func)
                        bt_ctf_field_type_copy,
                false, map_clock_classes_func,
-               (void *) bt_ctf_field_create,
-               (void *) bt_put,
-               (void *) create_event_header_field,
-               (void *) destroy_event_header_field);
+               (create_field_func) bt_ctf_field_create,
+               (release_field_func) bt_put,
+               (create_header_field_func) create_event_header_field,
+               (release_header_field_func) destroy_event_header_field);
        if (ret) {
                /* bt_event_common_initialize() logs errors */
                goto error;
This page took 0.029472 seconds and 4 git commands to generate.