Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions libutils/cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ void RegisterCleanupFunction(CleanupFn fn)
pthread_mutex_unlock(&cleanup_functions_mutex);
}

void ClearCleanupFunctions(void)
{
pthread_mutex_lock(&cleanup_functions_mutex);

CleanupList *p = cleanup_functions;
while (p)
{
CleanupList *cur = p;
p = cur->next;
free(cur);
}

cleanup_functions = NULL;

pthread_mutex_unlock(&cleanup_functions_mutex);
}

5 changes: 5 additions & 0 deletions libutils/cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ void CallCleanupFunctions(void);
void DoCleanupAndExit(int ret) FUNC_ATTR_NORETURN;
void RegisterCleanupFunction(CleanupFn fn);

/**
* Discards all currently registered cleanup functions without calling them.
*/
void ClearCleanupFunctions(void);

#endif
Loading