* Split the rte_acl_build_rule list into two lists. */
| 1205 | * Split the rte_acl_build_rule list into two lists. |
| 1206 | */ |
| 1207 | static void |
| 1208 | rule_list_split(struct rte_acl_build_rule *source, |
| 1209 | struct rte_acl_build_rule **list_a, |
| 1210 | struct rte_acl_build_rule **list_b) |
| 1211 | { |
| 1212 | struct rte_acl_build_rule *fast; |
| 1213 | struct rte_acl_build_rule *slow; |
| 1214 | |
| 1215 | if (source == NULL || source->next == NULL) { |
| 1216 | /* length < 2 cases */ |
| 1217 | *list_a = source; |
| 1218 | *list_b = NULL; |
| 1219 | } else { |
| 1220 | slow = source; |
| 1221 | fast = source->next; |
| 1222 | /* Advance 'fast' two nodes, and advance 'slow' one node */ |
| 1223 | while (fast != NULL) { |
| 1224 | fast = fast->next; |
| 1225 | if (fast != NULL) { |
| 1226 | slow = slow->next; |
| 1227 | fast = fast->next; |
| 1228 | } |
| 1229 | } |
| 1230 | /* 'slow' is before the midpoint in the list, so split it in two |
| 1231 | at that point. */ |
| 1232 | *list_a = source; |
| 1233 | *list_b = slow->next; |
| 1234 | slow->next = NULL; |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /* |
| 1239 | * Merge two sorted lists. |