X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=lib%2Fgraph%2Fnotification%2Fpacket.c;h=316eb61380a2a2486b01fb01986440f9ad8a3b02;hb=6c677fb54f458456e3b5a15cffa6774bd7a86f54;hp=17b00d463ee42a6c5341f25a98b3ffea0800cc61;hpb=3fea54f69edd1780566230255da196cb6e82df62;p=babeltrace.git diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c index 17b00d46..316eb613 100644 --- a/lib/graph/notification/packet.c +++ b/lib/graph/notification/packet.c @@ -37,6 +37,7 @@ #include #include #include +#include #include BT_HIDDEN @@ -87,10 +88,13 @@ struct bt_notification *bt_notification_packet_begin_create( &graph->packet_begin_notif_pool, graph); if (!notification) { /* bt_notification_create_from_pool() logs errors */ - goto error; + goto end; } - notification->packet = bt_get(packet); + BT_ASSERT(!notification->packet); + notification->packet = packet; + bt_object_get_no_null_check_no_parent_check( + ¬ification->packet->base); BT_LOGD("Created packet beginning notification object: " "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", " "stream-class-addr=%p, stream-class-name=\"%s\", " @@ -101,9 +105,6 @@ struct bt_notification *bt_notification_packet_begin_create( bt_stream_class_get_id(stream_class), notification); goto end; -error: - BT_PUT(notification); - end: return (void *) notification; } @@ -127,14 +128,15 @@ void bt_notification_packet_begin_recycle(struct bt_notification *notif) BT_ASSERT(packet_begin_notif); - if (!notif->graph) { + if (unlikely(!notif->graph)) { bt_notification_packet_begin_destroy(notif); return; } BT_LOGD("Recycling packet beginning notification: addr=%p", notif); bt_notification_reset(notif); - BT_PUT(packet_begin_notif->packet); + bt_object_put_no_null_check(&packet_begin_notif->packet->base); + packet_begin_notif->packet = NULL; graph = notif->graph; notif->graph = NULL; bt_object_pool_recycle_object(&graph->packet_begin_notif_pool, notif); @@ -201,10 +203,13 @@ struct bt_notification *bt_notification_packet_end_create( &graph->packet_end_notif_pool, graph); if (!notification) { /* bt_notification_create_from_pool() logs errors */ - goto error; + goto end; } - notification->packet = bt_get(packet); + BT_ASSERT(!notification->packet); + notification->packet = packet; + bt_object_get_no_null_check_no_parent_check( + ¬ification->packet->base); BT_LOGD("Created packet end notification object: " "packet-addr=%p, stream-addr=%p, stream-name=\"%s\", " "stream-class-addr=%p, stream-class-name=\"%s\", " @@ -215,9 +220,6 @@ struct bt_notification *bt_notification_packet_end_create( bt_stream_class_get_id(stream_class), notification); goto end; -error: - BT_PUT(notification); - end: return (void *) notification; }