Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rudolf
/
huffman
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
273b1678
authored
Nov 17, 2016
by
Rudolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compare original vs encoded file sizes
parent
eb9ada04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletions
huffman.c
tree.c
huffman.c
View file @
273b1678
...
@@ -140,9 +140,16 @@ int main(int argc, char *argv[])
...
@@ -140,9 +140,16 @@ int main(int argc, char *argv[])
if
(
decompress
)
if
(
decompress
)
ret
=
decode_file
(
input
,
output
);
ret
=
decode_file
(
input
,
output
);
else
else
{
ret
=
encode_file
(
input
,
output
);
ret
=
encode_file
(
input
,
output
);
long
insize
=
get_file_size
(
input
);
long
outsize
=
get_file_size
(
output
);
printf
(
"Original file size: %ld bytes
\n
"
,
insize
);
printf
(
"Huffman file size: %ld bytes
\n
"
,
outsize
);
}
fclose
(
input
);
fclose
(
input
);
fclose
(
output
);
fclose
(
output
);
return
ret
;
return
ret
;
...
...
tree.c
View file @
273b1678
...
@@ -35,6 +35,8 @@ struct tree *create_tree(FILE *file)
...
@@ -35,6 +35,8 @@ struct tree *create_tree(FILE *file)
if
(
c
==
EOF
||
c
>
MY_BUF
-
1
)
if
(
c
==
EOF
||
c
>
MY_BUF
-
1
)
break
;
break
;
/* While theoretically these files *can* be supported, Huffman is meant
* for text encoding/decoding, so we don't give a sh. */
if
(
c
>
MY_BUF
-
1
||
c
==
EOF_CHAR
)
{
if
(
c
>
MY_BUF
-
1
||
c
==
EOF_CHAR
)
{
fprintf
(
stderr
,
"File not supported
\n
"
);
fprintf
(
stderr
,
"File not supported
\n
"
);
return
NULL
;
return
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment