Skip to content
Snippets Groups Projects
Commit 0dcd29ed authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

compression: remove wire_pos context parameter

parent 13bf6bf5
No related branches found
No related tags found
No related merge requests found
......@@ -125,13 +125,17 @@ int knot_compr_put_dname(const knot_dname_t *dname, uint8_t *dst, uint16_t max,
written += sizeof(uint16_t);
}
assert(dst >= compr->wire);
size_t wire_pos = dst - compr->wire;
assert(wire_pos < KNOT_WIRE_MAX_PKTSIZE);
/* Heuristics - expect similar names are grouped together. */
if (written > sizeof(uint16_t) && compr->wire_pos + written < KNOT_WIRE_PTR_MAX) {
compr->suffix.pos = compr->wire_pos;
if (written > sizeof(uint16_t) && wire_pos + written < KNOT_WIRE_PTR_MAX) {
compr->suffix.pos = wire_pos;
compr->suffix.labels = orig_labels;
}
dbg_packet("%s: compressed to %u bytes (match=%zu,@%zu)\n",
__func__, written, dname - match_begin, compr->wire_pos);
__func__, written, dname - match_begin, wire_pos);
return written;
}
......
......@@ -69,7 +69,6 @@ typedef struct {
*/
typedef struct knot_compr {
uint8_t *wire; /* Packet wireformat. */
size_t wire_pos; /* Current wire position. */
knot_rrinfo_t *rrinfo; /* Hints for current RRSet. */
struct {
uint16_t pos; /* Position of current suffix. */
......
......@@ -495,7 +495,6 @@ int knot_pkt_put(knot_pkt_t *pkt, uint16_t compr_hint, const knot_rrset_t *rr,
/* Create compression context. */
knot_compr_t compr;
compr.wire = pkt->wire;
compr.wire_pos = pkt->size;
compr.rrinfo = rrinfo;
compr.suffix.pos = KNOT_WIRE_HEADER_SIZE;
compr.suffix.labels = knot_dname_labels(compr.wire + compr.suffix.pos,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment