From 2eb2f2e6ca13d84113e30041ade2dbfa9f4e1432 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Sat, 30 Dec 2017 09:30:03 +0100 Subject: nxcomp/src/Timestamp.{cpp,h}: use ::ctime_s or ::ctime_r instead of plain ctime, on-stack buffers and return std::string objects. Fixes: ArcticaProject/nx-libs#616 --- nxcomp/src/Timestamp.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'nxcomp/src/Timestamp.h') diff --git a/nxcomp/src/Timestamp.h b/nxcomp/src/Timestamp.h index bb9b243db..9e6fafcfd 100644 --- a/nxcomp/src/Timestamp.h +++ b/nxcomp/src/Timestamp.h @@ -26,11 +26,17 @@ #ifndef Timestamp_H #define Timestamp_H +#if HAVE_CTIME_S +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#endif /* HAVE_CTIME_S */ + #include #include #include +#include +#include -#include #include #include "Misc.h" @@ -260,15 +266,15 @@ inline int checkDiffTimestamp(const T_timestamp &ts1, const T_timestamp &ts2, // Return a string representing the timestamp. // -char *strTimestamp(const T_timestamp &ts); -char *strMsTimestamp(const T_timestamp &ts); +std::string strTimestamp(const T_timestamp &ts); +std::string strMsTimestamp(const T_timestamp &ts); -inline char *strTimestamp() +inline std::string strTimestamp() { return strTimestamp(getTimestamp()); } -inline char *strMsTimestamp() +inline std::string strMsTimestamp() { return strMsTimestamp(getTimestamp()); } -- cgit v1.2.3