diff --git a/zathura/document.c b/zathura/document.c index d302b3f..61f05b0 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -649,15 +649,13 @@ zathura_document_get_document_size(zathura_document_t* document, } void -zathura_document_set_cell_size(zathura_document_t* document, - unsigned int cell_height, - unsigned int cell_width) +zathura_document_set_cell_size(zathura_document_t* document, unsigned int cell_height, + unsigned int cell_width) { document->cell_width = cell_width; document->cell_height = cell_height; } - void zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding, unsigned int pages_per_row, unsigned int first_page_column) diff --git a/zathura/document.h b/zathura/document.h index f972f6f..a3ff280 100644 --- a/zathura/document.h +++ b/zathura/document.h @@ -328,7 +328,6 @@ ZATHURA_PLUGIN_API void zathura_document_get_cell_size(zathura_document_t* docum ZATHURA_PLUGIN_API void zathura_document_get_document_size(zathura_document_t* document, unsigned int* height, unsigned int* width); - /** * Sets the cell height and width of the document * diff --git a/zathura/zathura.c b/zathura/zathura.c index 0708584..50c1ef3 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -967,19 +967,25 @@ document_open_password_dialog(gpointer data) return FALSE; } -typedef struct sample_s { +typedef struct { double h; double w; - unsigned int freq; + int freq; } sample_t; -static int document_page_size_comp(const void *a, const void *b) { - return ((sample_t *)a)->freq - ((sample_t *)b)->freq; +static int +document_page_size_comp(const void *a, const void *b) +{ + const sample_t* lhs = a; + const sample_t* rhs = b; + return lhs->freq - rhs->freq; } -static void document_open_page_most_frequent_size(zathura_document_t *document, - unsigned int *width, - unsigned int *height) { +static void +document_open_page_most_frequent_size(zathura_document_t *document, + unsigned int *width, + unsigned int *height) +{ sample_t samples[32] = {{0}}; /* a max heap */ unsigned int number_of_pages = zathura_document_get_number_of_pages(document); unsigned int last_sample = (number_of_pages > 32) ? 32 : number_of_pages; @@ -1001,7 +1007,7 @@ static void document_open_page_most_frequent_size(zathura_document_t *document, } } - qsort((void *)samples, 32, sizeof(sample_t), document_page_size_comp); + qsort(samples, 32, sizeof(sample_t), document_page_size_comp); *width = samples[31].w; *height = samples[31].h;