diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 2b073b4b987..2af95e2bc36 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -362,7 +362,11 @@ void RoutingManager::Stop(void) SendRouterAdvertisement(kInvalidateAllPrevPrefixes); +#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE + mAdvertisedPrefixes.Free(); +#else mAdvertisedPrefixes.Clear(); +#endif mDiscoveredPrefixTable.RemoveAllEntries(); mDiscoveredPrefixStaleTimer.Stop(); diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index c78862931ba..55da201915b 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -54,6 +54,7 @@ #include "common/array.hpp" #include "common/error.hpp" #include "common/heap_allocatable.hpp" +#include "common/heap_array.hpp" #include "common/linked_list.hpp" #include "common/locator.hpp" #include "common/message.hpp" @@ -954,7 +955,12 @@ class RoutingManager : public InstanceLocator typedef Ip6::Prefix OnMeshPrefix; - class OnMeshPrefixArray : public Array + class OnMeshPrefixArray : +#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE + public Heap::Array +#else + public Array +#endif { public: void Add(const OnMeshPrefix &aPrefix); diff --git a/tests/toranj/openthread-core-toranj-config-posix.h b/tests/toranj/openthread-core-toranj-config-posix.h index 95cf37ac372..60e86777fcc 100644 --- a/tests/toranj/openthread-core-toranj-config-posix.h +++ b/tests/toranj/openthread-core-toranj-config-posix.h @@ -47,4 +47,7 @@ #define OPENTHREAD_POSIX_CONFIG_SPINEL_HDLC_INTERFACE_ENABLE 1 +// Disabled explicitly on posix `toranj` to validate the build with this config +#define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 0 + #endif /* OPENTHREAD_CORE_TORANJ_CONFIG_POSIX_H_ */ diff --git a/tests/toranj/openthread-core-toranj-config-simulation.h b/tests/toranj/openthread-core-toranj-config-simulation.h index 234465a6f09..8a1063c5cbd 100644 --- a/tests/toranj/openthread-core-toranj-config-simulation.h +++ b/tests/toranj/openthread-core-toranj-config-simulation.h @@ -59,6 +59,8 @@ #define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1 +#define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 1 + #define OPENTHREAD_CONFIG_RADIO_STATS_ENABLE 0 #endif /* OPENTHREAD_CORE_TORANJ_CONFIG_SIMULATION_H_ */