From: Geoffrey Allott Date: Wed, 24 Aug 2022 22:18:59 +0000 (+0100) Subject: swap args X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=70598fc0a3d443c4b5639f4a47497d64a0ecef80;p=tANS.git swap args --- diff --git a/src/stree.c b/src/stree.c index 9502117..61edfa1 100644 --- a/src/stree.c +++ b/src/stree.c @@ -105,7 +105,7 @@ static struct node *node_edge_decode(struct node *self, const uint8_t *str, stru return (struct node *) 0; } -static struct node *node_edge_encode(struct node *self, size_t i, const uint8_t *str, struct node **brother, bool seen[], uint8_t *code) +static struct node *node_edge_encode(struct node *self, const uint8_t *str, size_t i, struct node **brother, bool seen[], uint8_t *code) { struct node *node; @@ -122,7 +122,7 @@ static struct node *node_edge_encode(struct node *self, size_t i, const uint8_t return (struct node *) 0; } -static struct node *node_edge(struct node *self, size_t i, const uint8_t *str, struct node **brother) +static struct node *node_edge(struct node *self, const uint8_t *str, size_t i, struct node **brother) { struct node *node; @@ -139,7 +139,7 @@ static bool node_validate_suffix(struct node *self, size_t len, const uint8_t *s size_t j; if (len == 0) return true; - node = node_edge(self, i, str, &brother); + node = node_edge(self, str, i, &brother); if (!node) return false; for (j = node->from; j < node->to && len > 0; --len, ++j, ++i) { if (str[j] != str[i]) return false; @@ -203,9 +203,9 @@ int stree_encode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) memset(seen, 0, sizeof seen); code = 0; if (active_len == 0) - active_edge = node_edge_encode(active_node, i, in, &brother, seen, &code); + active_edge = node_edge_encode(active_node, in, i, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, in, &brother); + active_edge = node_edge(active_node, in, i - active_len, &brother); do { present = active_edge && in[active_edge->from+active_len] == in[i]; if (present) { @@ -230,9 +230,9 @@ int stree_encode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) if (active_len == 0 && active_node->son == nodes + n - 1) brother = active_edge = (struct node *) 0; else if (active_len == 0) - active_edge = node_edge_encode(active_node, i, in, &brother, seen, &code); + active_edge = node_edge_encode(active_node, in, i, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, in, &brother); + active_edge = node_edge(active_node, in, i - active_len, &brother); } while (active_edge && active_edge->from + active_len >= active_edge->to) { active_node = active_edge; @@ -240,9 +240,9 @@ int stree_encode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) if (active_len == 0 && present) brother = active_edge = (struct node *) 0; else if (active_len == 0) - active_edge = node_edge_encode(active_node, i, in, &brother, seen, &code); + active_edge = node_edge_encode(active_node, in, i, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, in, &brother); + active_edge = node_edge(active_node, in, i - active_len, &brother); } } while (rem > 0 && !present); if (!present) @@ -298,7 +298,7 @@ int stree_decode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) if (active_len == 0) active_edge = node_edge_decode(active_node, out, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, out, &brother); + active_edge = node_edge(active_node, out, i - active_len, &brother); do { present = active_edge && code == 0 && (active_len == 0 || !seen[out[active_edge->from+active_len]]); if (present) { @@ -326,7 +326,7 @@ int stree_decode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) else if (active_len == 0) active_edge = node_edge_decode(active_node, out, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, out, &brother); + active_edge = node_edge(active_node, out, i - active_len, &brother); } while (active_edge && active_edge->from + active_len >= active_edge->to) { active_node = active_edge; @@ -336,7 +336,7 @@ int stree_decode(size_t len, const uint8_t *in, uint8_t *out, size_t *aux) else if (active_len == 0) active_edge = node_edge_decode(active_node, out, &brother, seen, &code); else - active_edge = node_edge(active_node, i - active_len, out, &brother); + active_edge = node_edge(active_node, out, i - active_len, &brother); } } while (rem > 0 && !present); if (!present)