diff --git a/a.txt b/a.txt index 78edceb..67e84d8 100644 --- a/a.txt +++ b/a.txt @@ -31,39 +31,40 @@ make[2]: Leaving directory '/home/eason/Documents/project/HW11' [100%] Built target homework_11 make[1]: Leaving directory '/home/eason/Documents/project/HW11' /usr/bin/cmake -E cmake_progress_start /home/eason/Documents/project/HW11/CMakeFiles 0 -the number of prefixes with prefix length 0 = 0 -the number of prefixes with prefix length 1 = 0 -the number of prefixes with prefix length 2 = 0 -the number of prefixes with prefix length 3 = 1 -the number of prefixes with prefix length 4 = 0 -the number of prefixes with prefix length 5 = 1 -the number of prefixes with prefix length 6 = 3 -the number of prefixes with prefix length 7 = 4 -the number of prefixes with prefix length 8 = 107 -the number of prefixes with prefix length 9 = 3 -the number of prefixes with prefix length 10 = 5 -the number of prefixes with prefix length 11 = 9 -the number of prefixes with prefix length 12 = 47 -the number of prefixes with prefix length 13 = 70 -the number of prefixes with prefix length 14 = 164 -the number of prefixes with prefix length 15 = 317 -the number of prefixes with prefix length 16 = 6117 -the number of prefixes with prefix length 17 = 1083 -the number of prefixes with prefix length 18 = 1769 -the number of prefixes with prefix length 19 = 4489 -the number of prefixes with prefix length 20 = 5553 -the number of prefixes with prefix length 21 = 4246 -the number of prefixes with prefix length 22 = 6090 -the number of prefixes with prefix length 23 = 7772 -the number of prefixes with prefix length 24 = 43679 -the number of prefixes with prefix length 25 = 383 -the number of prefixes with prefix length 26 = 387 -the number of prefixes with prefix length 27 = 439 -the number of prefixes with prefix length 28 = 338 -the number of prefixes with prefix length 29 = 989 -the number of prefixes with prefix length 30 = 454 -the number of prefixes with prefix length 31 = 1 -the number of prefixes with prefix length 32 = 113 +The total number of prefixes in the input file is : 84633. +the number of prefixes with prefix length 0 = 0. +the number of prefixes with prefix length 1 = 0. +the number of prefixes with prefix length 2 = 0. +the number of prefixes with prefix length 3 = 1. +the number of prefixes with prefix length 4 = 0. +the number of prefixes with prefix length 5 = 1. +the number of prefixes with prefix length 6 = 3. +the number of prefixes with prefix length 7 = 4. +the number of prefixes with prefix length 8 = 107. +the number of prefixes with prefix length 9 = 3. +the number of prefixes with prefix length 10 = 5. +the number of prefixes with prefix length 11 = 9. +the number of prefixes with prefix length 12 = 47. +the number of prefixes with prefix length 13 = 70. +the number of prefixes with prefix length 14 = 164. +the number of prefixes with prefix length 15 = 317. +the number of prefixes with prefix length 16 = 6117. +the number of prefixes with prefix length 17 = 1083. +the number of prefixes with prefix length 18 = 1769. +the number of prefixes with prefix length 19 = 4489. +the number of prefixes with prefix length 20 = 5553. +the number of prefixes with prefix length 21 = 4246. +the number of prefixes with prefix length 22 = 6090. +the number of prefixes with prefix length 23 = 7772. +the number of prefixes with prefix length 24 = 43679. +the number of prefixes with prefix length 25 = 383. +the number of prefixes with prefix length 26 = 387. +the number of prefixes with prefix length 27 = 439. +the number of prefixes with prefix length 28 = 338. +the number of prefixes with prefix length 29 = 989. +the number of prefixes with prefix length 30 = 454. +the number of prefixes with prefix length 31 = 1. +the number of prefixes with prefix length 32 = 113. | 00000000 | | 00000001 | ---> | 1.0.0.0 | | 00000010 | ---> | 2.0.0.0 | diff --git a/homework_11 b/homework_11 index a5edad5..74c799a 100755 Binary files a/homework_11 and b/homework_11 differ diff --git a/src/v1.c b/src/v1.c index c5d6aed..c849463 100644 --- a/src/v1.c +++ b/src/v1.c @@ -7,18 +7,23 @@ void input(struct State* state){ FILE * table = fopen("routing_table.txt","r"); - + usize amount=0; + while(true){ char buffer[20]={'\0'}; fgets(buffer,20,table); if(*buffer=='\0') break; + amount++; + struct SizedSubmask* mask=malloc(sizeof(struct SizedSubmask)); parse_submask(buffer,mask); if(mask<10000)printf("%zu\n",mask); state->head=xor_insert_mid(NULL,state->head,mask); } + printf("The total number of prefixes in the input file is : %zu.\n",amount); + } void length_distribution(struct State* state){ @@ -37,5 +42,5 @@ void length_distribution(struct State* state){ } for(usize i=0;i<=32;i++) - printf("the number of prefixes with prefix length %zu = %zu\n",i,lens[i]); + printf("the number of prefixes with prefix length %zu = %zu.\n",i,lens[i]); } \ No newline at end of file diff --git a/src/v3.c b/src/v3.c index cb78060..5ed492e 100644 --- a/src/v3.c +++ b/src/v3.c @@ -58,7 +58,7 @@ void prefix_insert(struct State* state){ parse_submask(buffer,mask); struct SizedSubmask* ip=clone_submask(mask); - // record_start + record_start if(reduce_submask(mask)){ struct Node* ll=hash_pop(state->hashmap,mask); @@ -67,7 +67,7 @@ void prefix_insert(struct State* state){ hash_insert(state->hashmap,mask,new); }else state->head=xor_insert_mid(NULL,state->head,ip); - // record_end("prefix_insert.csv") + record_end("prefix_insert.csv") freq++; } @@ -93,6 +93,9 @@ void prefix_delete(struct State* state){ if(reduce_submask(mask)){ struct Node* ll=hash_pop(state->hashmap,mask); + if(ll==NULL){ + log_warn("not found"); + } struct Node* new_head=xor_remove_match(ll,ip,eq_v3); if(new_head!=NULL)hash_insert(state->hashmap,mask,new_head); @@ -105,7 +108,6 @@ void prefix_delete(struct State* state){ record_end("prefix_delete.csv") - free(ip); }