Commit 259f5553 by Rudolf

Add new compiler flag to turn on debugging features

parent 3e5150f8
Showing with 9 additions and 1 deletions
...@@ -5,6 +5,8 @@ SRC_FILES := \ ...@@ -5,6 +5,8 @@ SRC_FILES := \
huffman.c \ huffman.c \
print_helper.c print_helper.c
DEBUG := 1
default: default:
gcc $(SRC_FILES) -o huffman gcc $(SRC_FILES) -o huffman -DDEBUG=$(DEBUG)
...@@ -57,6 +57,9 @@ int encode_file(FILE *in, FILE *out) ...@@ -57,6 +57,9 @@ int encode_file(FILE *in, FILE *out)
if (!tree) if (!tree)
return -1; return -1;
if (DEBUG)
print_tree(tree);
encode_header(&bitbuf, tree); encode_header(&bitbuf, tree);
fseek(in, 0, SEEK_SET); fseek(in, 0, SEEK_SET);
...@@ -81,6 +84,9 @@ int decode_file(FILE *in, FILE *out) ...@@ -81,6 +84,9 @@ int decode_file(FILE *in, FILE *out)
decode_tree(&bitbuf, out, decoded); decode_tree(&bitbuf, out, decoded);
if (DEBUG)
print_tree(decoded);
free(decoded); free(decoded);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment