aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-28 11:13:32 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-28 11:13:32 +0100
commit0aaa6989c86eb6f15f49faee7ab0c013ebe89171 (patch)
treea4381f5c2261145a26e596cf82e009a209c91f54 /src/fig
parentc823c87d6f286310e9efd9e723f2e14c3320d31f (diff)
downloaddabmux-0aaa6989c86eb6f15f49faee7ab0c013ebe89171.tar.gz
dabmux-0aaa6989c86eb6f15f49faee7ab0c013ebe89171.tar.bz2
dabmux-0aaa6989c86eb6f15f49faee7ab0c013ebe89171.zip
Use reentrant gmtime and localtime functions, and other tweaks
Diffstat (limited to 'src/fig')
-rw-r--r--src/fig/FIG0_10.cpp16
-rw-r--r--src/fig/FIG0_9.cpp5
2 files changed, 11 insertions, 10 deletions
diff --git a/src/fig/FIG0_10.cpp b/src/fig/FIG0_10.cpp
index 3ce2847..56ce9fb 100644
--- a/src/fig/FIG0_10.cpp
+++ b/src/fig/FIG0_10.cpp
@@ -101,22 +101,22 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
buf += 2;
remaining -= 2;
- tm* timeData;
+ struct tm timeData;
time_t dab_time_seconds = 0;
uint32_t dab_time_millis = 0;
get_dab_time(&dab_time_seconds, &dab_time_millis);
- timeData = gmtime(&dab_time_seconds);
+ gmtime_r(&dab_time_seconds, &timeData);
fig0_10->RFU = 0;
- fig0_10->setMJD(gregorian2mjd(timeData->tm_year + 1900,
- timeData->tm_mon + 1,
- timeData->tm_mday));
+ fig0_10->setMJD(gregorian2mjd(timeData.tm_year + 1900,
+ timeData.tm_mon + 1,
+ timeData.tm_mday));
fig0_10->LSI = 0;
fig0_10->ConfInd = 1;
fig0_10->UTC = 1;
- fig0_10->setHours(timeData->tm_hour);
- fig0_10->Minutes = timeData->tm_min;
- fig0_10->Seconds = timeData->tm_sec;
+ fig0_10->setHours(timeData.tm_hour);
+ fig0_10->Minutes = timeData.tm_min;
+ fig0_10->Seconds = timeData.tm_sec;
fig0_10->setMilliseconds(dab_time_millis);
buf += 6;
remaining -= 6;
diff --git a/src/fig/FIG0_9.cpp b/src/fig/FIG0_9.cpp
index cf73625..dcee17c 100644
--- a/src/fig/FIG0_9.cpp
+++ b/src/fig/FIG0_9.cpp
@@ -139,8 +139,9 @@ FillStatus FIG0_9::fill(uint8_t *buf, size_t max_size)
if (ensemble->lto_auto) {
time_t now = time(NULL);
- struct tm* ltime = localtime(&now);
- time_t now2 = timegm(ltime);
+ struct tm ltime;
+ localtime_r(&now, &ltime);
+ time_t now2 = timegm(&ltime);
ensemble->lto = (now2 - now) / 1800;
}