293 int n = 0, err; |
293 int n = 0, err; |
294 uint64_t offset_flags; |
294 uint64_t offset_flags; |
295 int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2; |
295 int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2; |
296 const char *c_node_id; |
296 const char *c_node_id; |
297 const char *end = data + size; |
297 const char *end = data + size; |
|
298 char decode[64]; /* to enforce alignment with inline data */ |
298 |
299 |
299 while (data < end) { |
300 while (data < end) { |
300 unsigned int step; |
301 unsigned int step; |
301 |
302 |
302 offset_flags = ntohl(*((uint32_t *) (data + 4))); |
303 memcpy(decode, data, 64); |
|
304 offset_flags = ntohl(*((uint32_t *) (decode + 4))); |
303 if (n == 0) /* mask out version number for the first entry */ |
305 if (n == 0) /* mask out version number for the first entry */ |
304 offset_flags &= 0xFFFF; |
306 offset_flags &= 0xFFFF; |
305 else { |
307 else { |
306 uint32_t offset_high = ntohl(*((uint32_t *) data)); |
308 uint32_t offset_high = ntohl(*((uint32_t *) decode)); |
307 offset_flags |= ((uint64_t) offset_high) << 32; |
309 offset_flags |= ((uint64_t) offset_high) << 32; |
308 } |
310 } |
309 |
311 |
310 comp_len = ntohl(*((uint32_t *) (data + 8))); |
312 comp_len = ntohl(*((uint32_t *) (decode + 8))); |
311 uncomp_len = ntohl(*((uint32_t *) (data + 12))); |
313 uncomp_len = ntohl(*((uint32_t *) (decode + 12))); |
312 base_rev = ntohl(*((uint32_t *) (data + 16))); |
314 base_rev = ntohl(*((uint32_t *) (decode + 16))); |
313 link_rev = ntohl(*((uint32_t *) (data + 20))); |
315 link_rev = ntohl(*((uint32_t *) (decode + 20))); |
314 parent_1 = ntohl(*((uint32_t *) (data + 24))); |
316 parent_1 = ntohl(*((uint32_t *) (decode + 24))); |
315 parent_2 = ntohl(*((uint32_t *) (data + 28))); |
317 parent_2 = ntohl(*((uint32_t *) (decode + 28))); |
316 c_node_id = data + 32; |
318 c_node_id = decode + 32; |
317 |
319 |
318 entry = _build_idx_entry(nodemap, n, offset_flags, |
320 entry = _build_idx_entry(nodemap, n, offset_flags, |
319 comp_len, uncomp_len, base_rev, |
321 comp_len, uncomp_len, base_rev, |
320 link_rev, parent_1, parent_2, |
322 link_rev, parent_1, parent_2, |
321 c_node_id); |
323 c_node_id); |