change: simplify readout of offsets

laumann
Aug 16, 2022, 8:58 PM
AEMTSEJXOEXQTJEVUK3NGBP4ESM4UOFIXTBYUV7LEDZDJNKIA6CAC

Dependencies

  • [2] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change

Change contents

  • edit in change.c at line 9
    [2.1212][2.1212:1488]()
    /** Read a uint64_t from byte buffer as little endian */
    #define legetu64(buf) (((uint64_t)buf[7]) << 56 | (uint64_t)buf[6] << 48 | (uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 | (uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 | (uint64_t)buf[1] << 8 | (uint64_t)buf[0]);
  • edit in change.c at line 13
    [2.1539][2.1539:1547]()
    /* */
  • replacement in change.c at line 15
    [2.1587][2.1587:1603]()
    uint8_t *bufp;
    [2.1587]
    [2.1603]
    uint64_t *bufp;
  • replacement in change.c at line 28
    [2.1848][2.1848:2183]()
    bufp = (uint8_t *)buf;
    off->version = legetu64(bufp);
    bufp += 8;
    off->hashed_len = legetu64(bufp)
    bufp += 8;
    off->unhashed_off = legetu64(bufp)
    bufp += 8;
    off->unhashed_len = legetu64(bufp)
    bufp += 8;
    off->contents_off = legetu64(bufp)
    bufp += 8;
    off->contents_len = legetu64(bufp)
    bufp += 8;
    off->total = legetu64(bufp)
    [2.1848]
    [2.2183]
    /** Cast as []uint64_t */
    bufp = (uint64_t *)buf;
    off->version = *bufp++;
    off->hashed_len = *bufp++;
    off->unhashed_off = *bufp++;
    off->unhashed_len = *bufp++;
    off->contents_off = *bufp++;
    off->contents_len = *bufp++;
    off->total = *bufp;
  • edit in change.c at line 42
    [2.2198][2.2198:2199]()