Skip to content

Commit

Permalink
[routing-manager] use Heap::Array for OnMeshPrefixArray (openthre…
Browse files Browse the repository at this point in the history
…ad#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).
  • Loading branch information
abtink authored Nov 9, 2023
1 parent e987138 commit 0f55e79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/border_router/routing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 7 additions & 1 deletion src/core/border_router/routing_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -954,7 +955,12 @@ class RoutingManager : public InstanceLocator

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);
Expand Down
3 changes: 3 additions & 0 deletions tests/toranj/openthread-core-toranj-config-posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
2 changes: 2 additions & 0 deletions tests/toranj/openthread-core-toranj-config-simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit 0f55e79

Please sign in to comment.