Remove use of FOREACH macros

This commit is contained in:
Sebastian Ramacher 2023-12-03 23:38:58 +01:00
parent 61d6ff288f
commit 3841da009d

View File

@ -974,19 +974,14 @@ typedef struct {
int freq;
} sample_t;
static int
document_page_size_comp(const void *a, const void *b)
{
static int document_page_size_comp(const void* a, const void* b) {
const sample_t* lhs = a;
const sample_t* rhs = b;
return rhs->freq - lhs->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) {
girara_list_t* samples = girara_list_new2(g_free);
const unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
@ -996,13 +991,12 @@ document_open_page_most_frequent_size(zathura_document_t *document,
const double h = zathura_page_get_height(page);
bool found = false;
GIRARA_LIST_FOREACH_BODY(samples, sample_t*, sample,
for (size_t idx = 0; idx != girara_list_size(samples) && !found; ++idx) {
sample_t* sample = girara_list_nth(samples, idx);
if (fabs(sample->h - h) <= DBL_EPSILON && fabs(sample->w - w) <= DBL_EPSILON) {
sample->freq++;
found = true;
break;
}
);
}
if (found == false) {
sample_t* sample = g_try_malloc0(sizeof(sample_t));