From 7ce0942ee2e8375d279706e310486bf9e3fb860f Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 15 Dec 2023 10:51:56 +1030 Subject: [PATCH] common: Add trace_cleanup() function for unit tests --- common/trace.c | 8 ++++++++ common/trace.h | 1 + 2 files changed, 9 insertions(+) diff --git a/common/trace.c b/common/trace.c index 3cbb6c2ca..183368f68 100644 --- a/common/trace.c +++ b/common/trace.c @@ -195,6 +195,13 @@ void trace_span_resume(const void *key) current = trace_span_find(numkey); DTRACE_PROBE1(lightningd, span_resume, current->id); } + +void trace_cleanup(void) +{ + free(active_spans); + active_spans = NULL; +} + #else /* HAVE_USDT */ void trace_span_start(const char *name, const void *key) {} @@ -202,5 +209,6 @@ void trace_span_end(const void *key) {} void trace_span_suspend(const void *key) {} void trace_span_resume(const void *key) {} void trace_span_tag(const void *key, const char *name, const char *value) {} +void trace_cleanup(void) {} #endif /* HAVE_USDT */ diff --git a/common/trace.h b/common/trace.h index 7143659c9..cb2f916d9 100644 --- a/common/trace.h +++ b/common/trace.h @@ -7,5 +7,6 @@ void trace_span_end(const void *key); void trace_span_suspend(const void *key); void trace_span_resume(const void *key); void trace_span_tag(const void *key, const char *name, const char *value); +void trace_cleanup(void); #endif /* LIGHTNING_COMMON_TRACE_H */