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
1ac64069
authored
Nov 16, 2016
by
Rudolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic error checking
parent
f5fba026
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
huffman.c
huffman.c
View file @
1ac64069
...
@@ -51,7 +51,10 @@ int encode_file(FILE *in, FILE *out)
...
@@ -51,7 +51,10 @@ int encode_file(FILE *in, FILE *out)
long
size
=
get_file_size
(
in
);
long
size
=
get_file_size
(
in
);
fseek
(
in
,
0
,
SEEK_SET
);
fseek
(
in
,
0
,
SEEK_SET
);
tree
=
create_tree
(
in
);
tree
=
create_tree
(
in
);
if
(
!
tree
)
return
-
1
;
encode_header
(
&
bitbuf
,
tree
);
encode_header
(
&
bitbuf
,
tree
);
...
@@ -84,6 +87,7 @@ int decode_file(FILE *in, FILE *out)
...
@@ -84,6 +87,7 @@ int decode_file(FILE *in, FILE *out)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
;
const
char
*
infile
,
*
outfile
;
const
char
*
infile
,
*
outfile
;
bool
decompress
=
false
;
bool
decompress
=
false
;
...
@@ -118,11 +122,11 @@ int main(int argc, char *argv[])
...
@@ -118,11 +122,11 @@ int main(int argc, char *argv[])
}
}
if
(
decompress
)
if
(
decompress
)
decode_file
(
input
,
output
);
ret
=
decode_file
(
input
,
output
);
else
else
encode_file
(
input
,
output
);
ret
=
encode_file
(
input
,
output
);
fclose
(
input
);
fclose
(
input
);
fclose
(
output
);
fclose
(
output
);
return
0
;
return
ret
;
}
}
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