I was playing with the time.h
file in C that helps us with time/day functions.
I came across:
struct tm * _Cdecl localtime(const time_t
They return a pointer to a static struct local to the library. From the man page:
NOTES The four functions asctime(), ctime(), gmtime() and localtime() return a pointer to static data and hence are not thread-safe. Thread-safe versions asctime_r(), ctime_r(), gmtime_r() and localtime_r() are spec‐ ified by SUSv2, and available since libc 5.2.5. POSIX.1-2001 says: "The asctime(), ctime(), gmtime(), and localtime() functions shall return values in one of two static objects: a broken- down time structure and an array of type char. Execution of any of the functions may overwrite the information returned in either of these objects by any of the other functions." This can occur in the glibc implementation.