/** Deallocates memory previously allocated for the TrieNode. */
void trieFree(struct TrieNode* root) {
	if (!root)
		return;

	for (int i = 0; i < 26; i++) {
		trieFree(root->children[i - 'a']);
	}
	free(root);
}
void trieFree(struct TrieNode *root) {
	if (!root) return;
	int i;
	for (i = 0; i < MAX_SIZE; i++) {
		struct TrieNode *node = root->children[i];
		if (!node) trieFree(node);
	}
	free(root);
}
Ejemplo n.º 3
0
/** Deallocates memory previously allocated for the TrieNode. */
void trieFree(TrieNode* root) {
    if(root){
        unsigned int i;
        for(i = 0; i <=26; i ++)
        {
            trieFree(root->children[i]);
        }
        free(root);
    }
}
Ejemplo n.º 4
0
/** Deallocates memory previously allocated for the TrieNode. */
void trieFree(struct TrieNode* root) {
    if(root!=NULL)
    {
        for(int i=0; i<26; i++)
        {
            trieFree(root->children[i]);
        }
        free(root);
    }

}
/** Deallocates memory previously allocated for the TrieNode. */
void trieFree(struct TrieNode* root) {
	TrieNode* node = root->head;
	TrieNode* tmp;
	if (!node) {
		free(root);
		return;
	}

	while (node) {
		tmp = node;
		node = node->next;
		trieFree(tmp);
	}

	free(root);
}
Ejemplo n.º 6
0
/** Deallocates memory previously allocated for the TrieNode. */
void trieFree(struct TrieNode* root) {
    for (int i = 0; i<26; i++)
        if (root->next[i])
            trieFree(root->next[i]);
    free(root);
}
/** Deallocates memory previously allocated for the data structure. */
void wordDictionaryFree(struct WordDictionary* wordDictionary) {
	trieFree(wordDictionary->root);
	free(wordDictionary);
}