[routing-manager] use Heap::Array for OnMeshPrefixArray (#9592)

This commit updates `RoutingManager` to use heap allocated array
for `OnMeshPrefixArray` under `BORDER_ROUTING_USE_HEAP_ENABLE`
config.

This commit also updates the `toranj-config-posix` header to
explicitly disable `BORDER_ROUTING_USE_HEAP_ENABLE` under the POSIX
config to validate builds with this config disabled. This aligns with
the main purpose of the `toranj` posix build config, which is to
validate builds under different configs (run from the
`toranj-unittest` job in the `toranj.yml` GitHub action workflow).
This commit is contained in:
Abtin Keshavarzian
2023-11-09 15:31:41 -08:00
committed by GitHub
parent e987138701
commit 0f55e79263
4 changed files with 16 additions and 1 deletions
@@ -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();
+7 -1
View File
@@ -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 @@ private:
typedef Ip6::Prefix OnMeshPrefix;
class OnMeshPrefixArray : public Array<OnMeshPrefix, kMaxOnMeshPrefixes>
class OnMeshPrefixArray :
#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
public Heap::Array<OnMeshPrefix>
#else
public Array<OnMeshPrefix, kMaxOnMeshPrefixes>
#endif
{
public:
void Add(const OnMeshPrefix &aPrefix);
@@ -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_ */
@@ -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_ */