diff options
| author | 2017-01-28 04:55:59 +0100 | |
|---|---|---|
| committer | 2017-01-28 04:55:59 +0100 | |
| commit | 96ced4ea51df8d2816b5e0e97203be38949aa2b0 (patch) | |
| tree | dca471e58d1a3fab9df77d06830b7fab7eea44cc /src | |
| parent | 369d72bb954d0112c47af341ffff15d84228d3bb (diff) | |
| download | libplist-96ced4ea51df8d2816b5e0e97203be38949aa2b0.tar.gz libplist-96ced4ea51df8d2816b5e0e97203be38949aa2b0.tar.bz2 | |
bplist: Improve writing of offset table
Diffstat (limited to 'src')
| -rw-r--r-- | src/bplist.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/bplist.c b/src/bplist.c index 2121ef9..5a9d678 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -1163,18 +1163,9 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) | |||
| 1163 | buff_len = bplist_buff->len; | 1163 | buff_len = bplist_buff->len; |
| 1164 | offset_size = get_needed_bytes(buff_len); | 1164 | offset_size = get_needed_bytes(buff_len); |
| 1165 | offset_table_index = bplist_buff->len; | 1165 | offset_table_index = bplist_buff->len; |
| 1166 | for (i = 0; i < num_objects; i++) | 1166 | for (i = 0; i < num_objects; i++) { |
| 1167 | { | 1167 | uint64_t offset = be64toh(offsets[i]); |
| 1168 | uint8_t *offsetbuff = (uint8_t *) malloc(offset_size); | 1168 | byte_array_append(bplist_buff, (uint8_t*)&offset + (sizeof(uint64_t) - offset_size), offset_size); |
| 1169 | |||
| 1170 | #ifdef __BIG_ENDIAN__ | ||
| 1171 | offsets[i] = offsets[i] << ((sizeof(uint64_t) - offset_size) * 8); | ||
| 1172 | #endif | ||
| 1173 | |||
| 1174 | memcpy(offsetbuff, &offsets[i], offset_size); | ||
| 1175 | byte_convert(offsetbuff, offset_size); | ||
| 1176 | byte_array_append(bplist_buff, offsetbuff, offset_size); | ||
| 1177 | free(offsetbuff); | ||
| 1178 | } | 1169 | } |
| 1179 | 1170 | ||
| 1180 | //setup trailer | 1171 | //setup trailer |
