1 void Rotation_rules(int Preinstall_Series_Num, int Alternate_rule_num, Alternate_Rule_Struct *Alternate_rule, Preinstall_Work_Series_Struct *Preinstall_work_series, 2 link_list_before_struct **link_list_before, link_list_behind_struct **link_list_behind) 3 { 4 int i = 0, j = 0, k = 0, n = 0; 5 int count_before = 0, count_behind = 0; 6 7 (*link_list_before) = (link_list_before_struct *)calloc(Preinstall_Series_Num, sizeof(link_list_before_struct)); 8 (*link_list_behind) = (link_list_behind_struct *)calloc(Preinstall_Series_Num, sizeof(link_list_behind_struct)); 9 10 for(k = 0; k < Preinstall_Series_Num; k++) 11 { 12 count_before = 0; 13 count_behind = 0; 14 strcpy((*link_list_before)[k].banxi, Preinstall_work_series[k].Series_Name); 15 strcpy((*link_list_behind)[k].banxi, Preinstall_work_series[k].Series_Name); 16 (*link_list_before)[k].before = (char(*)[BANXI_LEN])calloc((count_before + 1), sizeof(char[BANXI_LEN])); 17 (*link_list_behind)[k].behind = (char(*)[BANXI_LEN])calloc((count_behind + 1), sizeof(char[BANXI_LEN]));//预先分配一个空间 18 for(i = 0; i < Alternate_rule_num; i++) 19 { 20 for(j = 0; j < Alternate_rule[i].Num_Alternate_rule_list; j++) 21 { 22 if(0 == strcmp(Alternate_rule[i].Alternate_rule_list[j].Next_Banxi, (*link_list_before)[k].banxi)) 23 { 24 strcpy((*link_list_before)[k].before + count_before, Alternate_rule[i].Alternate_rule_list[j].Banxi); 25 count_before++; 26 (*link_list_before)[k].before = (char(*)[BANXI_LEN])realloc((*link_list_before)[k].before, (count_before + 1) * sizeof(char[BANXI_LEN])); 27 memset((*link_list_before)[k].before + count_before, 0x0, BANXI_LEN); 28 } 29 if(0 == strcmp(Alternate_rule[i].Alternate_rule_list[j].Banxi, (*link_list_behind)[k].banxi)) 30 { 31 strcpy((*link_list_behind)[k].behind + count_behind, Alternate_rule[i].Alternate_rule_list[j].Next_Banxi); 32 count_behind++; 33 (*link_list_behind)[k].behind = (char(*)[BANXI_LEN])realloc((*link_list_behind)[k].behind, (count_behind + 1) * sizeof(char[BANXI_LEN])); 34 memset((*link_list_behind)[k].behind + count_behind, 0x0, BANXI_LEN); 35 36 } 37 } 38 } 39 (*link_list_before)[k].Count = count_before; 40 (*link_list_behind)[k].Count = count_behind; 41 } 42 }