CP-Templates
CP-Templates copied to clipboard
Potential memory leak for Trie template
using g++ (GCC) 14.1.1 20240720
with compiler argument -fsanitize=address
Address Sanitizer will report the memory leaks.
~Trie() {
deleteNode(root);
}
void deleteNode(Node* node) {
if (!node) return;
for (int i = 0; i < charSize(); ++i) {
deleteNode(node->children[i]);
}
delete node;
}
fixes the leak.