They're done in the same step. result = _regex_find_all(root, &clear_ll, -1); ll_clear(&clear_ll); Is all that's necessary to reset all nodes, since the only value that changes during the match is list_id, and that gets set when the nodes are found.