sort: simplify file_reader_clean
Deindent the function, remove useless tests: - free already test if argument is NULL - closefile already test if the input is stdin or null
This commit is contained in:
parent
f9d9a7cc4f
commit
ffd41d39c6
@ -574,7 +574,7 @@ openfile(const char *fn, const char *mode)
|
||||
void
|
||||
closefile(FILE *f, const char *fn)
|
||||
{
|
||||
if (f == NULL || f = stdin)
|
||||
if (f == NULL || f == stdin)
|
||||
return;
|
||||
if (f == stdout) {
|
||||
fflush(f);
|
||||
@ -699,26 +699,19 @@ static void
|
||||
file_reader_clean(struct file_reader *fr)
|
||||
{
|
||||
|
||||
if (fr) {
|
||||
if (fr == NULL)
|
||||
return;
|
||||
|
||||
if (fr->mmapaddr)
|
||||
munmap(fr->mmapaddr, fr->mmapsize);
|
||||
|
||||
if (fr->fd)
|
||||
close(fr->fd);
|
||||
|
||||
if (fr->buffer)
|
||||
sort_free(fr->buffer);
|
||||
|
||||
if (fr->file)
|
||||
if (fr->file != stdin)
|
||||
free(fr->buffer);
|
||||
closefile(fr->file, fr->fname);
|
||||
|
||||
if(fr->fname)
|
||||
sort_free(fr->fname);
|
||||
|
||||
free(fr->fname);
|
||||
memset(fr, 0, sizeof(struct file_reader));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
file_reader_free(struct file_reader *fr)
|
||||
|
Loading…
Reference in New Issue
Block a user