MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / remove_last_node

Function remove_last_node

nanofi/src/core/string_utils.c:79–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void 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
109void attach_lists(token_list * to, token_list * from) {
110 if (to && validate_list(from)) {

Callers 1

tokenize_string_tailfileFunction · 0.85

Calls 3

validate_listFunction · 0.85
free_all_tokensFunction · 0.85
free_token_nodeFunction · 0.85

Tested by

no test coverage detected