Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Use localtime_r over localtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Aug 31, 2023
1 parent 0735220 commit 2bd8c66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/Irrlicht/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define bswap_16(X) _byteswap_ushort(X)
#define bswap_32(X) _byteswap_ulong(X)
#define bswap_64(X) _byteswap_uint64(X)
#define localtime _localtime_s
#elif defined(_IRR_OSX_PLATFORM_)
#include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0)
Expand All @@ -40,6 +39,10 @@
#define bswap_64(X) ((((X)&0x00000000000000FF) << 56) | (((X)&0xFF00000000000000) >> 56) | (((X)&0x000000000000FF00) << 40) | (((X)&0x00FF000000000000) >> 40) | (((X)&0x0000000000FF0000) << 24) | (((X)&0x0000FF0000000000) >> 24) | (((X)&0x00000000FF000000) << 8) | (((X) &0x000000FF00000000) >> 8))
#endif

#if defined(_IRR_WINDOWS_API_)
#define localtime_r(a, b) localtime_s(b, a)
#endif

namespace irr
{
namespace os
Expand Down Expand Up @@ -303,8 +306,9 @@ namespace os
time_t rawtime;
time(&rawtime);

struct tm * timeinfo;
timeinfo = localtime(&rawtime);
struct tm timeinfo2;
localtime_r(&rawtime, &timeinfo2);
const auto *timeinfo = &timeinfo2;

// init with all 0 to indicate error
ITimer::RealTimeDate date;
Expand Down

0 comments on commit 2bd8c66

Please sign in to comment.