trace2 / tr2_tbuf.con commit rebase: fix a memory leak (7372eae)
   1#include "cache.h"
   2#include "tr2_tbuf.h"
   3
   4void tr2_tbuf_local_time(struct tr2_tbuf *tb)
   5{
   6        struct timeval tv;
   7        struct tm tm;
   8        time_t secs;
   9
  10        gettimeofday(&tv, NULL);
  11        secs = tv.tv_sec;
  12        localtime_r(&secs, &tm);
  13
  14        xsnprintf(tb->buf, sizeof(tb->buf), "%02d:%02d:%02d.%06ld", tm.tm_hour,
  15                  tm.tm_min, tm.tm_sec, (long)tv.tv_usec);
  16}
  17
  18void tr2_tbuf_utc_time(struct tr2_tbuf *tb)
  19{
  20        struct timeval tv;
  21        struct tm tm;
  22        time_t secs;
  23
  24        gettimeofday(&tv, NULL);
  25        secs = tv.tv_sec;
  26        gmtime_r(&secs, &tm);
  27
  28        xsnprintf(tb->buf, sizeof(tb->buf),
  29                  "%4d-%02d-%02d %02d:%02d:%02d.%06ld", tm.tm_year + 1900,
  30                  tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
  31                  (long)tv.tv_usec);
  32}