Skip to content

Commit a132239

Browse files
author
zhouwg
committed
ggml-hexagon: make helper function ggmlhexagon_get_timestring() thread-safe
1 parent 4dbde9c commit a132239

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ggml/src/ggml-hexagon/ggml-hexagon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,16 +837,16 @@ static const char * ggmlhexagon_get_hwaccel_approach_name(int hwaccle_approach)
837837
static void ggmlhexagon_get_timestring(char * p_currenttime) {
838838
#if defined(__ANDROID__) || defined(__linux__)
839839
time_t n_seconds = 0;
840-
struct tm * p_tm = nullptr;
840+
struct tm now_time;
841841

842842
if (nullptr == p_currenttime)
843843
return;
844844

845845
time(&n_seconds);
846-
p_tm = localtime(&n_seconds);
846+
localtime_r(&n_seconds, &now_time);
847847
snprintf(p_currenttime, GGMLHEXAGON_TMPBUF_LEN, "%04d-%02d-%02d,%02d:%02d:%02d",
848-
p_tm->tm_year + 1900, p_tm->tm_mon + 1, p_tm->tm_mday,
849-
p_tm->tm_hour, p_tm->tm_min, p_tm->tm_sec);
848+
now_time.tm_year + 1900, now_time.tm_mon + 1, now_time.tm_mday,
849+
now_time.tm_hour, now_time.tm_min, now_time.tm_sec);
850850
#else
851851
//TODO: WoA
852852
#endif

0 commit comments

Comments
 (0)