[message] simplify method for allocating new message from pool (#7210)

This commit removes different `MessagePool` methods that can be used
to allocate a new message  and combines them into one `Allocate()`
method which uses `Message::Settings`. The `Message::Settings` is
also updated to provide new constructor initializing it with a given
message priority only.
This commit is contained in:
Abtin Keshavarzian
2021-11-29 13:46:07 -08:00
committed by GitHub
parent 912eca181d
commit 16798fdcc0
18 changed files with 67 additions and 80 deletions
+3 -3
View File
@@ -65,7 +65,7 @@ void TestMessage(void)
Random::NonCrypto::FillBuffer(writeBuffer, kMaxSize);
VerifyOrQuit((message = messagePool->New(Message::kTypeIp6, 0)) != nullptr);
VerifyOrQuit((message = messagePool->Allocate(Message::kTypeIp6)) != nullptr);
SuccessOrQuit(message->SetLength(kMaxSize));
message->WriteBytes(0, writeBuffer, kMaxSize);
SuccessOrQuit(message->Read(0, readBuffer, kMaxSize));
@@ -136,7 +136,7 @@ void TestMessage(void)
// Test `Message::CopyTo()` behavior.
VerifyOrQuit((message2 = messagePool->New(Message::kTypeIp6, 0)) != nullptr);
VerifyOrQuit((message2 = messagePool->Allocate(Message::kTypeIp6)) != nullptr);
SuccessOrQuit(message2->SetLength(kMaxSize));
for (uint16_t srcOffset = 0; srcOffset < kMaxSize; srcOffset += kOffsetStep)
@@ -258,7 +258,7 @@ void TestAppender(void)
instance = static_cast<Instance *>(testInitInstance());
VerifyOrQuit(instance != nullptr);
message = instance->Get<MessagePool>().New(Message::kTypeIp6, 0);
message = instance->Get<MessagePool>().Allocate(Message::kTypeIp6);
VerifyOrQuit(message != nullptr);
memset(buffer, 0, sizeof(buffer));