format
This commit is contained in:
9
src/v1.c
9
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]);
|
||||
}
|
8
src/v3.c
8
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user