mirror of
https://github.com/espressif/openthread.git
synced 2026-07-09 05:40:27 +00:00
[instance] check the instance to be valid in platform callbacks (#2005)
This commit adds a new API `otInstanceIsInitialized()` to check if a given instance is valid, i.e, it has been initialized and not finalized. We then use this function to verify that passed-in instance argument in platform callbacks is valid.
This commit is contained in:
committed by
Jonathan Hui
parent
3883017fd8
commit
08367625e5
@@ -155,6 +155,11 @@ exit:
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool otInstanceIsInitialized(otInstance *aInstance)
|
||||
{
|
||||
return (aInstance != NULL);
|
||||
}
|
||||
|
||||
#else // #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
|
||||
otInstance *otInstanceInitSingle(void)
|
||||
@@ -181,6 +186,11 @@ exit:
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
bool otInstanceIsInitialized(otInstance *aInstance)
|
||||
{
|
||||
return (aInstance != NULL) && (aInstance == sInstance);
|
||||
}
|
||||
|
||||
#endif // #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
|
||||
void otInstanceFinalize(otInstance *aInstance)
|
||||
|
||||
Reference in New Issue
Block a user