From 34b9a6f054b2428edc499c78abbd2cb4e4a1f05f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 14 Sep 2018 10:27:12 +0200 Subject: [PATCH] tprofile: fix tprofile_start1 when id==NULL --- src/tprofile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tprofile.c b/src/tprofile.c index 17568f257..ad2b7099b 100644 --- a/src/tprofile.c +++ b/src/tprofile.c @@ -17,6 +17,7 @@ */ #include +#include #include "tvhlog.h" #include "clock.h" #include "tprofile.h" @@ -72,7 +73,13 @@ void tprofile_start1(tprofile_t *tprof, const char *id) pthread_mutex_lock(&tprofile_mutex); assert(tprof->start == 0); tprof->start = getfastmonoclock(); - tprof->start_id = strdup(id); + if (id) { + tprof->start_id = strdup(id); + } else { + char buf[32]; + snprintf(buf, sizeof(buf), "[%p]", tprof); + tprof->start_id = strdup(buf); + } pthread_mutex_unlock(&tprofile_mutex); } -- 2.47.2