mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 07:35:59 +01:00
Simplify
This commit is contained in:
parent
43144b23e8
commit
5a5ee06407
1 changed files with 6 additions and 8 deletions
|
@ -179,12 +179,10 @@ guess_type_glib(const char* path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int fd = fileno(f);
|
|
||||||
guchar* content = NULL;
|
guchar* content = NULL;
|
||||||
size_t length = 0u;
|
size_t length = 0;
|
||||||
ssize_t bytes_read = -1;
|
while (uncertain == TRUE && length < GT_MAX_READ) {
|
||||||
while (uncertain == TRUE && length < GT_MAX_READ && bytes_read != 0) {
|
g_free(content_type);
|
||||||
g_free((void*)content_type);
|
|
||||||
content_type = NULL;
|
content_type = NULL;
|
||||||
|
|
||||||
guchar* temp_content = g_try_realloc(content, length + BUFSIZ);
|
guchar* temp_content = g_try_realloc(content, length + BUFSIZ);
|
||||||
|
@ -193,8 +191,8 @@ guess_type_glib(const char* path)
|
||||||
}
|
}
|
||||||
content = temp_content;
|
content = temp_content;
|
||||||
|
|
||||||
bytes_read = read(fd, content + length, BUFSIZ);
|
size_t bytes_read = fread(content + length, 1, BUFSIZ, f);
|
||||||
if (bytes_read == -1) {
|
if (bytes_read == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +207,7 @@ guess_type_glib(const char* path)
|
||||||
return content_type;
|
return content_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free((void*)content_type);
|
g_free(content_type);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue