From 324d88100de8f76f976e0e0f64cc7f6c6623ac65 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 8 Feb 2018 22:07:34 +0100 Subject: [PATCH] Mark functions as const --- zathura/document.c | 14 +++++++------- zathura/page.c | 20 ++++++++++---------- zathura/plugin.c | 4 ++-- zathura/plugin.h | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/zathura/document.c b/zathura/document.c index bf6539d..f463187 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -144,7 +144,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri, file = NULL; /* open document */ - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->document_open == NULL) { girara_error("plugin has no open function\n"); goto error_free; @@ -221,7 +221,7 @@ zathura_document_free(zathura_document_t* document) /* free document */ zathura_error_t error = ZATHURA_ERROR_OK; - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_free == NULL) { error = ZATHURA_ERROR_NOT_IMPLEMENTED; } else { @@ -619,7 +619,7 @@ zathura_document_save_as(zathura_document_t* document, const char* path) return ZATHURA_ERROR_UNKNOWN; } - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_save_as == NULL) { return ZATHURA_ERROR_NOT_IMPLEMENTED; } @@ -635,7 +635,7 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e return NULL; } - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_index_generate == NULL) { check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED); return NULL; @@ -652,7 +652,7 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* return NULL; } - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_attachments_get == NULL) { check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED); return NULL; @@ -668,7 +668,7 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac return ZATHURA_ERROR_INVALID_ARGUMENTS; } - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_attachment_save == NULL) { return ZATHURA_ERROR_NOT_IMPLEMENTED; } @@ -684,7 +684,7 @@ zathura_document_get_information(zathura_document_t* document, zathura_error_t* return NULL; } - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin); if (functions->document_get_information == NULL) { check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED); return NULL; diff --git a/zathura/page.c b/zathura/page.c index 9659227..799cc27 100644 --- a/zathura/page.c +++ b/zathura/page.c @@ -45,7 +45,7 @@ zathura_page_new(zathura_document_t* document, unsigned int index, zathura_error /* init plugin */ zathura_plugin_t* plugin = zathura_document_get_plugin(document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_init == NULL) { if (error != NULL) { @@ -88,7 +88,7 @@ zathura_page_free(zathura_page_t* page) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_clear == NULL) { return ZATHURA_ERROR_NOT_IMPLEMENTED; } @@ -211,7 +211,7 @@ zathura_page_search_text(zathura_page_t* page, const char* text, zathura_error_t } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_search_text == NULL) { if (error != NULL) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -233,7 +233,7 @@ zathura_page_links_get(zathura_page_t* page, zathura_error_t* error) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_links_get == NULL) { if (error != NULL) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -261,7 +261,7 @@ zathura_page_form_fields_get(zathura_page_t* page, zathura_error_t* error) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_form_fields_get == NULL) { if (error != NULL) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -289,7 +289,7 @@ zathura_page_images_get(zathura_page_t* page, zathura_error_t* error) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_images_get == NULL) { if (error != NULL) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -311,7 +311,7 @@ zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathu } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_image_get_cairo == NULL) { if (error != NULL) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -333,7 +333,7 @@ zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathu } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_get_text == NULL) { if (error) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; @@ -352,7 +352,7 @@ zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_render_cairo == NULL) { return ZATHURA_ERROR_NOT_IMPLEMENTED; } @@ -371,7 +371,7 @@ zathura_page_get_label(zathura_page_t* page, zathura_error_t* error) } zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); - zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); if (functions->page_get_label == NULL) { if (error) { *error = ZATHURA_ERROR_NOT_IMPLEMENTED; diff --git a/zathura/plugin.c b/zathura/plugin.c index e186153..69fa7d4 100644 --- a/zathura/plugin.c +++ b/zathura/plugin.c @@ -343,11 +343,11 @@ plugin_add_mimetype(zathura_plugin_t* plugin, const char* mime_type) } } -zathura_plugin_functions_t* +const zathura_plugin_functions_t* zathura_plugin_get_functions(zathura_plugin_t* plugin) { if (plugin != NULL) { - return &(plugin->functions); + return &plugin->functions; } else { return NULL; } diff --git a/zathura/plugin.h b/zathura/plugin.h index d69745e..e0a8c22 100644 --- a/zathura/plugin.h +++ b/zathura/plugin.h @@ -63,7 +63,7 @@ girara_list_t* zathura_plugin_manager_get_plugins(zathura_plugin_manager_t* plug * @param plugin The plugin * @return The plugin functions */ -zathura_plugin_functions_t* zathura_plugin_get_functions(zathura_plugin_t* plugin); +const zathura_plugin_functions_t* zathura_plugin_get_functions(zathura_plugin_t* plugin); /** * Returns the name of the plugin