]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tprofile: fix tprofile_start1 when id==NULL
authorJaroslav Kysela <perex@perex.cz>
Fri, 14 Sep 2018 08:27:12 +0000 (10:27 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 14 Sep 2018 08:27:12 +0000 (10:27 +0200)
src/tprofile.c

index 17568f2572e5bd43ef6e1ae8f177d19df123b8b7..ad2b7099bcd42445b63c876293938fb080dec4ac 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <assert.h>
+#include <stdio.h>
 #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);
 }