macro cleanup

This commit is contained in:
hladu357 2024-06-06 14:41:03 +02:00
parent eccff7691f
commit 62f174b9c9
1 changed files with 6 additions and 8 deletions

View File

@ -1,13 +1,9 @@
#include "trie.h"
#define RULES_FILE "../data/routing-data"
#define TEST_FILE "../data/test-data"
#define TEST_ROWS 11 /*17217*/
#define READ_MODE "r"
#define RULE_NOT_FOUND -1
#define GET_BIT(key, bit) ( ( key.s[ bit / 16 ] & (1u << (15 - bit % 16)) ) != 0 )
trie_node_t create_node() {
trie_node_t ret = calloc(1, sizeof(struct trie_node)); /* sets null childs and invalid */
return ret;
@ -57,8 +53,7 @@ int trie_insert(trie_holder_t t, ipv6_t key, int val, int mask) {
iter->_rule_valid = VALID_RULE;
iter->_rule = val;
return 1;
return ++t->_size;;
}
int trie_search(trie_holder_t t, ipv6_t key) {
@ -81,12 +76,15 @@ int trie_search(trie_holder_t t, ipv6_t key) {
/*--------------------------------------------------------------------------------*/
/* TESTING */
/*--------------------------------------------------------------------------------*/
#include <assert.h>
#define RULES_FILE "../data/routing-data"
#define TEST_FILE "../data/test-data"
#define TEST_ROWS 5721
int parse_line(ipv6_t* key, int* val, int* mask, FILE* f) { /*! assumes only good input */
memset(key, 0, sizeof(ipv6_t));
@ -157,7 +155,7 @@ int fire_tests(trie_holder_t t, ipv6_t* ips, int* ref, int num_tests ) {
for (row = 0; row < TEST_ROWS; ++ row) {
if (trie_search(t, ips[row]) != ref[row]) {
printf("%d %d @ %d\n", trie_search(t, ips[row]), ref[row], row );
printf("ref: %d got: %d @ %d\n", ref[row], trie_search(t, ips[row]), row );
++wrong;
}
}