summaryrefslogtreecommitdiffstats
path: root/src/bplist.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/bplist.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/bplist.c')
-rw-r--r--src/bplist.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/bplist.c b/src/bplist.c
index bb73b31..fbe1b63 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -284,11 +284,7 @@ static plist_t parse_date_node(const char **bnode, uint8_t size)
plist_t node = parse_real_node(bnode, size);
plist_data_t data = plist_get_data(node);
- double time_real = data->realval;
- data->timeval.tv_sec = (long) time_real;
- data->timeval.tv_usec = (time_real - (long) time_real) * 1000000;
data->type = PLIST_DATE;
- data->length = sizeof(struct timeval);
return node;
}
@@ -728,6 +724,7 @@ static unsigned int plist_data_hash(const void* key)
case PLIST_BOOLEAN:
case PLIST_UINT:
case PLIST_REAL:
+ case PLIST_DATE:
case PLIST_UID:
buff = (char *) &data->intval; //works also for real as we use an union
size = 8;
@@ -744,10 +741,6 @@ static unsigned int plist_data_hash(const void* key)
buff = (char *) &key;
size = sizeof(const void*);
break;
- case PLIST_DATE:
- buff = (char *) &(data->timeval);
- size = data->length;
- break;
default:
break;
}
@@ -1183,7 +1176,7 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
write_dict(bplist_buff, ptr_array_index(objects, i), ref_table, dict_param_size);
break;
case PLIST_DATE:
- write_date(bplist_buff, data->timeval.tv_sec + (double) data->timeval.tv_usec / 1000000);
+ write_date(bplist_buff, data->realval);
break;
case PLIST_UID:
write_uid(bplist_buff, data->intval);