libhal-google / libhal-util

libhal utility functions, interface wrappers, and types to help manage usage of embedded resources
Apache License 2.0
1 stars 4 forks source link

:bug: Fix move ctor for `hal::static_list` & `hal::can_router` #45

Closed kammce closed 1 year ago

kammce commented 1 year ago

Remove usage of hal::move_interceptor for hal::can_router. The major issue with hal::move_interceptor is that it results in an exact clone between both objects. There is no way for either object to know its a "moved-from" object and thus when they destruct or are destroyed, they end up disabling both objects as they have common resources.

Move constructor for hal::can_router now reassigns the can receive handler to the new object and sets the pointer to the can peripheral on the moved-from object is set to nullptr to differentiate between objects.

Move constructor for hal::static_list makes the moved-from empty and also moves all of the list item from the moved-from list to the new list.