edit in change.c at line 166
[3.1172]→[3.619:632](∅→∅) edit in change.c at line 172
+ struct bincode_state binstat;
replacement in change.c at line 199
− p = buf;
− dump_buf("hashed", p, hashed_len);
+ binstat.avail = hashed_len;
+ binstat.buf = buf;
+ dump_buf("hashed", buf, hashed_len);
replacement in change.c at line 203
− hashed.version = bincode_getu64(&p);
+ hashed.version = bincode_getu64(&binstat);
replacement in change.c at line 206
− len = bincode_getu64(&p);
+ len = bincode_getu64(&binstat);
replacement in change.c at line 208
− hashed.header.message = bincode_getstr(&p, len);
+ hashed.header.message = bincode_getstr(&binstat, len);
replacement in change.c at line 216
[3.1130]→[3.1130:1143](∅→∅),
[3.1143]→[2.140:223](∅→∅) − if (*p++) {
− len = bincode_getu64(&p);
− hashed.header.description = bincode_getstr(&p, len);
+ if (bincode_getu8(&binstat)) {
+ len = bincode_getu64(&binstat);
+ hashed.header.description = bincode_getstr(&binstat, len);
replacement in change.c at line 223
[3.1368]→[2.224:251](∅→∅) − len = bincode_getu64(&p);
+ len = bincode_getu64(&binstat);
replacement in change.c at line 227
[3.1520]→[2.252:304](∅→∅) − hashed.header.timestamp = bincode_getstr(&p, len);
+ hashed.header.timestamp = bincode_getstr(&binstat, len);
edit in bincode.h at line 12
+ */
+
+ /**
+ * This approach could simplify signatures a bit (in the sense of changing to a
+ * single pointer again). It would also allow adding some bounds checking that
+ * we aren't trying to read more data than available in the buffer. Maybe a case
+ * for "if (unlikely(s->len - s->count < sizeof(type)))" ?
edit in bincode.h at line 20
+ struct bincode_state {
+ size_t avail; /* bytes still available */
+ uint8_t *buf;
+ };
replacement in bincode.h at line 31
[3.2156]→[2.305:416](∅→∅) − uint16_t bincode_getu16(uint8_t **);
− uint32_t bincode_getu32(uint8_t **);
− uint64_t bincode_getu64(uint8_t **);
+ uint8_t bincode_getu8(struct bincode_state *);
+ uint16_t bincode_getu16(struct bincode_state *);
+ uint32_t bincode_getu32(struct bincode_state *);
+ uint64_t bincode_getu64(struct bincode_state *);
replacement in bincode.h at line 44
[3.2502]→[2.417:459](∅→∅) − char *bincode_getstr(uint8_t **, size_t);
+ char *bincode_getstr(struct bincode_state *, size_t);
edit in bincode.c at line 7
+
+ uint8_t
+ bincode_getu8(struct bincode_state *s)
+ {
+ uint8_t ret;
edit in bincode.c at line 13
edit in bincode.c at line 15
+ s->avail -= sizeof(uint8_t);
+ return ret;
+ }
+
replacement in bincode.c at line 20
[3.2866]→[2.460:489](∅→∅) − bincode_getu16(uint8_t **bp)
+ bincode_getu16(struct bincode_state *s)
replacement in bincode.c at line 25
replacement in bincode.c at line 28
− *bp += sizeof(uint16_t);
+ s->avail -= sizeof(uint16_t);
replacement in bincode.c at line 33
[3.2953]→[2.616:645](∅→∅) − bincode_getu32(uint8_t **bp)
+ bincode_getu32(struct bincode_state *s)
replacement in bincode.c at line 38
replacement in bincode.c at line 44
− *bp += sizeof(uint32_t);
+ s->avail -= sizeof(uint32_t);
replacement in bincode.c at line 49
[3.3092]→[2.756:785](∅→∅) − bincode_getu64(uint8_t **bp)
+ bincode_getu64(struct bincode_state *s)
replacement in bincode.c at line 54
replacement in bincode.c at line 64
− *bp += sizeof(uint64_t);
+ s->avail -= sizeof(uint64_t);
replacement in bincode.c at line 69
[3.3329]→[2.895:935](∅→∅) − bincode_getstr(uint8_t **b, size_t len)
+ bincode_getstr(struct bincode_state *s, size_t len)
edit in bincode.c at line 72
edit in bincode.c at line 74
replacement in bincode.c at line 76
[3.3408]→[2.936:959](∅→∅) replacement in bincode.c at line 78
[3.3448]→[2.960:972](∅→∅)