]> PatchyGit - patchyircd.git/commitdiff
trie_find: underscore the internal fields
authorEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 21:36:00 +0000 (00:36 +0300)
committerEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 21:36:00 +0000 (00:36 +0300)
src/map.h
src/map_trie.c

index 02f62d2..0479bc5 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -43,9 +43,9 @@ struct trie_node {
 typedef struct trie_node *map_t;
 #define TRIE_MAX_KEY 256
 struct trie_find {
-       struct trie_node *n;
+       struct trie_node *_n;
        void *value;
-       size_t len;
+       size_t _len;
        char key[TRIE_MAX_KEY];
 };
 typedef struct trie_find *map_find_t;
index 5c28b20..e91e082 100644 (file)
@@ -140,24 +140,24 @@ int map_findnext(map_find_t *pf) {
        map_find_t f = *pf;
        int ent = 0; // go to the first child node
        for (;;) {
-               if (!trie_is_end(ent, f->n)) {
-                       f->n = f->n->data[ent];
-                       f->key[f->len++] = f->n->key;
-                       if (f->n->value) { // found a value
-                               f->key[f->len] = '\0';
-                               f->value = f->n->value;
+               if (!trie_is_end(ent, f->_n)) {
+                       f->_n = f->_n->data[ent];
+                       f->key[f->_len++] = f->_n->key;
+                       if (f->_n->value) { // found a value
+                               f->key[f->_len] = '\0';
+                               f->value = f->_n->value;
                                return 1;
                        }
                        ent = 0; // no value, go to the first child
                } else { // no more children, go to parent's next child
-                       f->n = f->n->parent;
-                       if (!f->n) {
+                       f->_n = f->_n->parent;
+                       if (!f->_n) {
                                *pf = NULL;
                                free(f);
                                return 0;
                        }
-                       f->len--;
-                       ent = ent_find(f->n, (unsigned char)f->key[f->len] + 1);
+                       f->_len--;
+                       ent = ent_find(f->_n, (unsigned char)f->key[f->_len] + 1);
                }
        }
 }
@@ -171,12 +171,12 @@ int map_findfirst(map_find_t *pf, map_t *root) {
                f = *pf = malloc(sizeof(*f));
                if (!f)
                        return -1;
-               f->len = 0;
+               f->_len = 0;
        }
-       f->n = *root;
-       if (f->n->value) {
-               f->key[f->len] = '\0';
-               f->value = f->n->value;
+       f->_n = *root;
+       if (f->_n->value) {
+               f->key[f->_len] = '\0';
+               f->value = f->_n->value;
                return 1;
        }
        return map_findnext(pf);