@@ -402,13 +402,13 @@ CANARD_PRIVATE int32_t txPushSingleFrame(struct CanardTxQueue* const que,
402402
403403 // Insert the newly created TX item into the priority queue.
404404 const struct cavl2_t * const priority_queue_res =
405- cavlSearch (& que -> priority_root , & tqi -> priority_base , & txAVLPriorityPredicate , & avlTrivialFactory );
405+ cavl2_find_or_insert (& que -> priority_root , & tqi -> priority_base , & txAVLPriorityPredicate , & avlTrivialFactory );
406406 (void ) priority_queue_res ;
407407 CANARD_ASSERT (priority_queue_res == & tqi -> priority_base );
408408
409409 // Insert the newly created TX item into the deadline queue.
410410 const struct cavl2_t * const deadline_queue_res =
411- cavlSearch (& que -> deadline_root , & tqi -> deadline_base , & txAVLDeadlinePredicate , & avlTrivialFactory );
411+ cavl2_find_or_insert (& que -> deadline_root , & tqi -> deadline_base , & txAVLDeadlinePredicate , & avlTrivialFactory );
412412 (void ) deadline_queue_res ;
413413 CANARD_ASSERT (deadline_queue_res == & tqi -> deadline_base );
414414
@@ -552,14 +552,18 @@ CANARD_PRIVATE int32_t txPushMultiFrame(struct CanardTxQueue* const que,
552552 struct CanardTxQueueItem * next = sq .head ;
553553 do
554554 {
555- const struct cavl2_t * const priority_queue_res =
556- cavlSearch (& que -> priority_root , & next -> priority_base , & txAVLPriorityPredicate , & avlTrivialFactory );
555+ const struct cavl2_t * const priority_queue_res = cavl2_find_or_insert (& que -> priority_root ,
556+ & next -> priority_base ,
557+ & txAVLPriorityPredicate ,
558+ & avlTrivialFactory );
557559 (void ) priority_queue_res ;
558560 CANARD_ASSERT (priority_queue_res == & next -> priority_base );
559561 CANARD_ASSERT (que -> priority_root != NULL );
560562
561- const struct cavl2_t * const deadline_queue_res =
562- cavlSearch (& que -> deadline_root , & next -> deadline_base , & txAVLDeadlinePredicate , & avlTrivialFactory );
563+ const struct cavl2_t * const deadline_queue_res = cavl2_find_or_insert (& que -> deadline_root ,
564+ & next -> deadline_base ,
565+ & txAVLDeadlinePredicate ,
566+ & avlTrivialFactory );
563567 (void ) deadline_queue_res ;
564568 CANARD_ASSERT (deadline_queue_res == & next -> deadline_base );
565569 CANARD_ASSERT (que -> deadline_root != NULL );
@@ -1341,10 +1345,11 @@ int8_t canardRxAccept(struct CanardInstance* const ins,
13411345 // This is the reason the function has a logarithmic time complexity of the number of subscriptions.
13421346 // Note also that this one of the two variable-complexity operations in the RX pipeline; the other one
13431347 // is memcpy(). Excepting these two cases, the entire RX pipeline contains neither loops nor recursion.
1344- struct cavl2_t * const sub_node = cavlSearch (& ins -> rx_subscriptions [(size_t ) model .transfer_kind ],
1345- & model .port_id ,
1346- & rxSubscriptionPredicateOnPortID ,
1347- NULL );
1348+ struct cavl2_t * const sub_node =
1349+ cavl2_find_or_insert (& ins -> rx_subscriptions [(size_t ) model .transfer_kind ],
1350+ & model .port_id ,
1351+ & rxSubscriptionPredicateOnPortID ,
1352+ NULL );
13481353 struct CanardRxSubscription * const sub =
13491354 MUTABLE_CONTAINER_OF (struct CanardRxSubscription , sub_node , base );
13501355 if (out_subscription != NULL )
@@ -1402,10 +1407,10 @@ int8_t canardRxSubscribe(struct CanardInstance* const ins,
14021407 // We could accept an extra argument that would instruct us to pre-allocate sessions here?
14031408 out_subscription -> sessions [i ] = NULL ;
14041409 }
1405- const struct cavl2_t * const res = cavlSearch (& ins -> rx_subscriptions [tk ],
1406- & out_subscription -> base ,
1407- & rxSubscriptionPredicateOnStruct ,
1408- & avlTrivialFactory );
1410+ const struct cavl2_t * const res = cavl2_find_or_insert (& ins -> rx_subscriptions [tk ],
1411+ & out_subscription -> base ,
1412+ & rxSubscriptionPredicateOnStruct ,
1413+ & avlTrivialFactory );
14091414 (void ) res ;
14101415 CANARD_ASSERT (res == & out_subscription -> base );
14111416 out = (out > 0 ) ? 0 : 1 ;
@@ -1424,7 +1429,7 @@ int8_t canardRxUnsubscribe(struct CanardInstance* const ins,
14241429 {
14251430 CanardPortID port_id_mutable = port_id ;
14261431
1427- struct cavl2_t * const sub_node = cavlSearch ( //
1432+ struct cavl2_t * const sub_node = cavl2_find_or_insert ( //
14281433 & ins -> rx_subscriptions [tk ],
14291434 & port_id_mutable ,
14301435 & rxSubscriptionPredicateOnPortID ,
@@ -1467,7 +1472,7 @@ int8_t canardRxGetSubscription(struct CanardInstance* const ins,
14671472 {
14681473 CanardPortID port_id_mutable = port_id ;
14691474
1470- struct cavl2_t * const sub_node = cavlSearch ( //
1475+ struct cavl2_t * const sub_node = cavl2_find_or_insert ( //
14711476 & ins -> rx_subscriptions [tk ],
14721477 & port_id_mutable ,
14731478 & rxSubscriptionPredicateOnPortID ,
0 commit comments