1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1704 - Reenable an hook if it is reattached

This commit is contained in:
Alessio Morale 2015-02-05 15:42:58 +01:00
parent a8e89dffcd
commit 108c74da3e

View File

@ -341,7 +341,18 @@ FrameType_t GetCurrentFrameType()
void SANITYCHECK_AttachHook(SANITYCHECK_CustomHook_function *hook) void SANITYCHECK_AttachHook(SANITYCHECK_CustomHook_function *hook)
{ {
PIOS_Assert(hook); PIOS_Assert(hook);
SANITYCHECK_CustomHookInstance *instance = (SANITYCHECK_CustomHookInstance *)pios_malloc(sizeof(SANITYCHECK_CustomHookInstance)); SANITYCHECK_CustomHookInstance *instance = NULL;
// Check whether there is an existing instance and enable it
LL_FOREACH(hooks, instance) {
if (instance->hook == hook) {
instance->enabled = true;
return;
}
}
// No existing instance found, attach this new one
instance = (SANITYCHECK_CustomHookInstance *)pios_malloc(sizeof(SANITYCHECK_CustomHookInstance));
PIOS_Assert(instance); PIOS_Assert(instance);
instance->hook = hook; instance->hook = hook;
instance->next = NULL; instance->next = NULL;