| 77 | } |
| 78 | |
| 79 | void remove_last_node(token_list * tks) { |
| 80 | if (!validate_list(tks)) { |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | if (tks->size == 1 || tks->head == tks->tail) { |
| 85 | tks->total_bytes -= strlen(tks->tail->data); |
| 86 | free_all_tokens(tks); |
| 87 | tks->head = NULL; |
| 88 | tks->tail = NULL; |
| 89 | tks->size = 0; |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | struct token_node * tmp_head = tks->head; |
| 94 | struct token_node * tmp_tail = tks->tail; |
| 95 | |
| 96 | while (tmp_head->next && (tmp_head->next != tmp_tail)) { |
| 97 | tmp_head = tmp_head->next; |
| 98 | } |
| 99 | |
| 100 | struct token_node * tail_node = tmp_tail; |
| 101 | tks->tail = tmp_head; |
| 102 | tks->tail->next = NULL; |
| 103 | |
| 104 | tks->size--; |
| 105 | tks->total_bytes -= (strlen(tail_node->data)); |
| 106 | free_token_node(tail_node); |
| 107 | } |
| 108 | |
| 109 | void attach_lists(token_list * to, token_list * from) { |
| 110 | if (to && validate_list(from)) { |
no test coverage detected