Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinas committed May 13, 2024
1 parent 84810fd commit 87f1491
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions zathura/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ char* zathura_get_version_string(zathura_t* zathura, bool markup) {
}
}

#if GLIB_CHECK_VERSION(2, 76, 0)
return g_string_free_and_steal(string);
#else
return g_string_free(string, FALSE);
#endif
}

GdkAtom* get_selection(zathura_t* zathura) {
Expand Down Expand Up @@ -277,15 +281,20 @@ char* write_first_page_column_list(unsigned int* first_page_columns, unsigned in
return NULL;
}

char** tokens = g_malloc0_n(size + 1, sizeof(char*));
GString* buffer = g_string_new(NULL);
for (unsigned int i = 0; i < size; i++) {
tokens[i] = g_strdup_printf("%d", first_page_columns[i]);
if (i != 0) {
g_string_append_printf(buffer, ":%u", first_page_columns[i]);
} else {
g_string_append_printf(buffer, "%u", first_page_columns[i]);
}
}

char* first_page_column_list = g_strjoinv(":", tokens);
g_strfreev(tokens);

return first_page_column_list;
#if GLIB_CHECK_VERSION(2, 76, 0)
return g_string_free_and_steal(buffer);
#else
return g_string_free(buffer, FALSE);
#endif
}

unsigned int* parse_first_page_column_list(const char* first_page_column_list, unsigned int* size) {
Expand Down

0 comments on commit 87f1491

Please sign in to comment.