mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 08:36:01 +01:00
Fix return type
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
dd67476912
commit
8946015219
4 changed files with 17 additions and 21 deletions
|
@ -82,7 +82,7 @@ zathura_content_type_free(zathura_content_type_context_t* context)
|
|||
static const size_t GT_MAX_READ = 1 << 16;
|
||||
|
||||
#ifdef WITH_MAGIC
|
||||
static const char*
|
||||
static char*
|
||||
guess_type_magic(zathura_content_type_context_t* context, const char* path)
|
||||
{
|
||||
if (context == NULL || context->magic == NULL) {
|
||||
|
@ -97,15 +97,13 @@ guess_type_magic(zathura_content_type_context_t* context, const char* path)
|
|||
girara_debug("failed guessing filetype: %s", magic_error(context->magic));
|
||||
return NULL;
|
||||
}
|
||||
/* dup so we own the memory */
|
||||
mime_type = g_strdup(mime_type);
|
||||
|
||||
girara_debug("magic detected filetype: %s", mime_type);
|
||||
|
||||
return mime_type;
|
||||
/* dup so we own the memory */
|
||||
return g_strdup(mime_type);;
|
||||
}
|
||||
|
||||
static const char*
|
||||
static char*
|
||||
guess_type_file(const char* UNUSED(path))
|
||||
{
|
||||
return NULL;
|
||||
|
@ -118,7 +116,7 @@ guess_type_magic(zathura_content_type_context_t* UNUSED(context),
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const char*
|
||||
static char*
|
||||
guess_type_file(const char* path)
|
||||
{
|
||||
GString* command = g_string_new("file -b --mime-type ");
|
||||
|
@ -149,11 +147,11 @@ guess_type_file(const char* path)
|
|||
}
|
||||
#endif
|
||||
|
||||
static const char*
|
||||
static char*
|
||||
guess_type_glib(const char* path)
|
||||
{
|
||||
gboolean uncertain = FALSE;
|
||||
const char* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
|
||||
char* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
|
||||
if (content_type == NULL) {
|
||||
girara_debug("g_content_type failed\n");
|
||||
} else {
|
||||
|
@ -203,12 +201,12 @@ guess_type_glib(const char* path)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char*
|
||||
char*
|
||||
zathura_content_type_guess(zathura_content_type_context_t* context,
|
||||
const char* path)
|
||||
{
|
||||
/* try libmagic first */
|
||||
const char* content_type = guess_type_magic(context, path);
|
||||
char* content_type = guess_type_magic(context, path);
|
||||
if (content_type != NULL) {
|
||||
return content_type;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ void zathura_content_type_free(zathura_content_type_context_t* context);
|
|||
* the available libraries.
|
||||
*
|
||||
* @param path file name
|
||||
* @return content type of path
|
||||
* @return content type of path, needs to freeed with g_free.
|
||||
*/
|
||||
const char* zathura_content_type_guess(zathura_content_type_context_t* context,
|
||||
char* zathura_content_type_guess(zathura_content_type_context_t* context,
|
||||
const char* path);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -70,7 +70,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
|||
|
||||
GFile* file = g_file_new_for_path(path);
|
||||
char* real_path = NULL;
|
||||
const char* content_type = NULL;
|
||||
char* content_type = NULL;
|
||||
zathura_plugin_t* plugin = NULL;
|
||||
zathura_document_t* document = NULL;
|
||||
|
||||
|
@ -106,7 +106,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
|||
goto error_free;
|
||||
}
|
||||
|
||||
g_free((void*)content_type);
|
||||
g_free(content_type);
|
||||
content_type = NULL;
|
||||
|
||||
document = g_try_malloc0(sizeof(zathura_document_t));
|
||||
|
|
|
@ -52,15 +52,13 @@ file_valid_extension(zathura_t* zathura, const char* path)
|
|||
return false;
|
||||
}
|
||||
|
||||
const gchar* content_type =
|
||||
zathura_content_type_guess(zathura->content_type_context, path);
|
||||
char* content_type = zathura_content_type_guess(zathura->content_type_context, path);
|
||||
if (content_type == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
zathura_plugin_t* plugin =
|
||||
zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
|
||||
g_free((void*)content_type);
|
||||
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
|
||||
g_free(content_type);
|
||||
|
||||
return (plugin == NULL) ? false : true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue