Skip to content

pointers to pointers considered harmful #421

Description

@thirtytwobits

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    class-requirementIssue that can be traced back to a design requiementdomain-productionPertains to the shippable code rather than any scaffoldingpriority-lowA minor issue

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions