summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2016-09-19 01:49:05 +0200
committerGravatar Nikias Bassen2016-09-19 01:49:05 +0200
commit912cb45928f03355ca162a2f1286ca49eb58155c (patch)
tree2069bf08b56c04b3e194a3ac7515e897e2e12880 /src/xplist.c
parenta348ba9aa866e7e97fd7bf819af38c8c9107ebb5 (diff)
downloadlibplist-912cb45928f03355ca162a2f1286ca49eb58155c.tar.gz
libplist-912cb45928f03355ca162a2f1286ca49eb58155c.tar.bz2
Change internal storage of PLIST_DATE values from struct timeval to double
This removes the timeval union member from the plist_data_t structure. Since struct timeval is 2x64bit on 64bit platforms this member unnecessarily grew the union size to 16 bytes while a size of 8 bytes is sufficient. Also, on 32bit platforms struct timeval is only 2x32bit of size, limiting the range of possible time values. In addition the binary property list format also stores PLIST_DATE nodes as double.
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 8fe3604..e55a094 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -258,7 +258,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
258 case PLIST_DATE: 258 case PLIST_DATE:
259 tag = XPLIST_DATE; 259 tag = XPLIST_DATE;
260 { 260 {
261 time_t timev = (time_t)node_data->timeval.tv_sec + MAC_EPOCH; 261 time_t timev = (time_t)node_data->realval + MAC_EPOCH;
262 struct tm *btime = gmtime(&timev); 262 struct tm *btime = gmtime(&timev);
263 if (btime) { 263 if (btime) {
264 val = (char*)malloc(24); 264 val = (char*)malloc(24);
@@ -462,10 +462,9 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
462 tm_utc = gmtime(&timev); 462 tm_utc = gmtime(&timev);
463 timev -= (mktime(tm_utc) - timev); 463 timev -= (mktime(tm_utc) - timev);
464 } 464 }
465 data->timeval.tv_sec = (long)(timev - MAC_EPOCH); 465 data->realval = (double)(timev - MAC_EPOCH);
466 data->timeval.tv_usec = 0;
467 data->type = PLIST_DATE; 466 data->type = PLIST_DATE;
468 data->length = sizeof(struct timeval); 467 data->length = sizeof(double);
469 xmlFree(strval); 468 xmlFree(strval);
470 continue; 469 continue;
471 } 470 }