Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pointers to pointers considered harmful #421

Open
thirtytwobits opened this issue Jan 29, 2025 · 0 comments
Open

pointers to pointers considered harmful #421

thirtytwobits opened this issue Jan 29, 2025 · 0 comments
Labels
class-requirement Issue that can be traced back to a design requiement domain-production Pertains to the shippable code rather than any scaffolding priority-low A minor issue

Comments

@thirtytwobits
Copy link
Contributor

thirtytwobits commented Jan 29, 2025

both can_transport_impl and udp_transport_impl have makeTransport methods that take a span of IMedia*. This is a pointer to pointers which means a simple implementation with only one IMedia implementation has to add an additional memory location to store a pointer to the one implementation.

struct MyApplication {
    MyApplication()
        : only_one_of_me_{}
        , i_hate_this_{&only_one_of_me_}
    {
        libcyphal::transport::udp::makeTransport(
        {
            *cetl::pmr::get_default_resource(),
        },
        my_executor,
        cetl::span<libcyphal::transport::udp::IMedia*>{&i_hate_this_, 1},
        tx_capacity);
    }

    MyMediaObject only_one_of_me_;
    MyMediaObject* i_hate_this_;
};

Solutions include a different override for this case or std::reference_wrapper in the span.

@pavel-kirienko pavel-kirienko added priority-low A minor issue domain-production Pertains to the shippable code rather than any scaffolding class-requirement Issue that can be traced back to a design requiement labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
class-requirement Issue that can be traced back to a design requiement domain-production Pertains to the shippable code rather than any scaffolding priority-low A minor issue
Projects
None yet
Development

No branches or pull requests

2 participants