mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 23:09:53 +00:00
[test] move heap plat APIs in unit test under extern "C" block (#9766)
This commit is contained in:
@@ -342,6 +342,36 @@ otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
|
|||||||
return OT_ERROR_NONE;
|
return OT_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Array<void *, 500> sHeapAllocatedPtrs;
|
||||||
|
|
||||||
|
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
||||||
|
|
||||||
|
void *otPlatCAlloc(size_t aNum, size_t aSize)
|
||||||
|
{
|
||||||
|
void *ptr = calloc(aNum, aSize);
|
||||||
|
|
||||||
|
SuccessOrQuit(sHeapAllocatedPtrs.PushBack(ptr));
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void otPlatFree(void *aPtr)
|
||||||
|
{
|
||||||
|
if (aPtr != nullptr)
|
||||||
|
{
|
||||||
|
void **entry = sHeapAllocatedPtrs.Find(aPtr);
|
||||||
|
|
||||||
|
VerifyOrQuit(entry != nullptr, "A heap allocated item is freed twice");
|
||||||
|
sHeapAllocatedPtrs.Remove(*entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(aPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -536,35 +566,6 @@ exit:
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Array<void *, 500> sHeapAllocatedPtrs;
|
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
|
||||||
|
|
||||||
void *otPlatCAlloc(size_t aNum, size_t aSize)
|
|
||||||
{
|
|
||||||
void *ptr = calloc(aNum, aSize);
|
|
||||||
|
|
||||||
SuccessOrQuit(sHeapAllocatedPtrs.PushBack(ptr));
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void otPlatFree(void *aPtr)
|
|
||||||
{
|
|
||||||
if (aPtr != nullptr)
|
|
||||||
{
|
|
||||||
void **entry = sHeapAllocatedPtrs.Find(aPtr);
|
|
||||||
|
|
||||||
VerifyOrQuit(entry != nullptr, "A heap allocated item is freed twice");
|
|
||||||
sHeapAllocatedPtrs.Remove(*entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(aPtr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void LogRouterAdvert(const Icmp6Packet &aPacket)
|
void LogRouterAdvert(const Icmp6Packet &aPacket)
|
||||||
{
|
{
|
||||||
Ip6::Nd::RouterAdvertMessage raMsg(aPacket);
|
Ip6::Nd::RouterAdvertMessage raMsg(aPacket);
|
||||||
|
|||||||
Reference in New Issue
Block a user