[coap] rename message setup methods to use AllocateAndInit prefix (#12613)

This commit updates the names of several message allocation methods in
`CoapBase` to `AllocateAndInit*()`. This change helps to clearly
differentiate these methods from the `NewPriorityMessage()` and
`NetMessage()` overloads, which only allocate a new `Message`.

In contrast, the `AllocateAndInit` methods allocate the message and
fully prepare it by initializing the CoAP header, appending the URI
path option, the payload marker, leaving it ready for the payload.
This change clarifies the design by explicitly indicating that these
methods perform extra setup work.

All calls to these methods throughout the codebase have been updated
to reflect the new names.
This commit is contained in:
Abtin Keshavarzian
2026-03-04 15:25:41 -06:00
committed by GitHub
parent 1f6e339a9a
commit 26a9d6da3f
37 changed files with 177 additions and 151 deletions
+3 -3
View File
@@ -3264,7 +3264,7 @@ Error Mle::SendAddressSolicit(RouterUpgradeReason aReason)
VerifyOrExit(!mAddressSolicitPending);
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(kUriAddressSolicit);
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriAddressSolicit);
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
SuccessOrExit(error = Tlv::Append<ThreadExtMacAddressTlv>(*message, Get<Mac::Mac>().GetExtAddress()));
@@ -3298,7 +3298,7 @@ void Mle::SendAddressRelease(void)
Coap::Message *message;
Ip6::Address leaderRloc;
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(kUriAddressRelease);
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriAddressRelease);
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
SuccessOrExit(error = Tlv::Append<ThreadRloc16Tlv>(*message, Rloc16FromRouterId(mRouterId)));
@@ -3576,7 +3576,7 @@ template <> void Mle::HandleTmf<kUriAddressSolicit>(Coap::Msg &aMsg)
// Prepare and send response
response = Get<Tmf::Agent>().NewPriorityResponseMessage(aMsg.mMessage);
response = Get<Tmf::Agent>().AllocateAndInitPriorityResponseFor(aMsg.mMessage);
VerifyOrExit(response != nullptr);
SuccessOrExit(Tlv::Append<ThreadStatusTlv>(*response, info.mResponse));