mirror of
https://github.com/espressif/openthread.git
synced 2026-09-06 09:10:04 +00:00
[instance-locator] use instance reference instead of pointer (#2007)
This commit changes the `InstanceLocator` class to keep track of a reference to `otInstance` (instead of a pointer) to make it behave similar to other `ObjectLocator` classes. The method `GetInstance()` in all locator objects is updated to provide a reference (instead of a pointer) to `otInstance`. The logging macros are updated such that a reference to `otInstance` is passed as the first argument (with the exception of `otLog<Level>Plat()` macros which are used by platform code in C domain). The documentation for log macros are also updated.
This commit is contained in:
committed by
Jonathan Hui
parent
ea73c92151
commit
fc72e4e719
@@ -82,19 +82,19 @@ otInstance *testInitInstance(void)
|
||||
otInstance *instance = NULL;
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
size_t instaneBufferLength = 0;
|
||||
size_t instanceBufferLength = 0;
|
||||
uint8_t *instanceBuffer = NULL;
|
||||
|
||||
// Call to query the buffer size
|
||||
(void)otInstanceInit(NULL, &instaneBufferLength);
|
||||
(void)otInstanceInit(NULL, &instanceBufferLength);
|
||||
|
||||
// Call to allocate the buffer
|
||||
instanceBuffer = (uint8_t *)malloc(instaneBufferLength);
|
||||
instanceBuffer = (uint8_t *)malloc(instanceBufferLength);
|
||||
VerifyOrQuit(instanceBuffer != NULL, "Failed to allocate otInstance");
|
||||
memset(instanceBuffer, 0, instaneBufferLength);
|
||||
memset(instanceBuffer, 0, instanceBufferLength);
|
||||
|
||||
// Initialize OpenThread with the buffer
|
||||
instance = otInstanceInit(instanceBuffer, &instaneBufferLength);
|
||||
instance = otInstanceInit(instanceBuffer, &instanceBufferLength);
|
||||
#else
|
||||
instance = otInstanceInitSingle();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user