Обновить sk1/compressor.c
This commit is contained in:
parent
0c18bdde02
commit
2aa747983d
@ -149,12 +149,13 @@ void generateCodes(HuffmanNode* root, char* arr, int top, char** codes) {
|
|||||||
codes[root->data] = strdup(arr);
|
codes[root->data] = strdup(arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void free_huffman_tree(Node* root) {
|
void free_huffman_tree(HuffmanNode* root) {
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
free_huffman_tree(root->left);
|
free_huffman_tree(root->left);
|
||||||
free_huffman_tree(root->right);
|
free_huffman_tree(root->right);
|
||||||
free(root);
|
free(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to compress a file
|
// Function to compress a file
|
||||||
int compress_1(const char* input_file, const char* output_file) {
|
int compress_1(const char* input_file, const char* output_file) {
|
||||||
FILE* input = fopen(input_file, "rb");
|
FILE* input = fopen(input_file, "rb");
|
||||||
@ -290,4 +291,4 @@ int decompress_1(const char* input_file_name, const char* output_file_name) {
|
|||||||
fclose(output);
|
fclose(output);
|
||||||
free_huffman_tree(root);
|
free_huffman_tree(root);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user