diff --git a/zathura/content-type.c b/zathura/content-type.c index 9352da1..3440973 100644 --- a/zathura/content-type.c +++ b/zathura/content-type.c @@ -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; } diff --git a/zathura/content-type.h b/zathura/content-type.h index c02d937..9bd367d 100644 --- a/zathura/content-type.h +++ b/zathura/content-type.h @@ -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, - const char* path); +char* zathura_content_type_guess(zathura_content_type_context_t* context, + const char* path); #endif diff --git a/zathura/document.c b/zathura/document.c index f4563b7..7ed9acb 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -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)); diff --git a/zathura/utils.c b/zathura/utils.c index ea5bc2b..d99a461 100644 --- a/zathura/utils.c +++ b/zathura/utils.c @@ -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; }