[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:
Abtin Keshavarzian
2017-07-19 22:12:24 -07:00
committed by Jonathan Hui
parent 3883017fd8
commit 08367625e5
6 changed files with 77 additions and 7 deletions
+10
View File
@@ -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)