Update for changes in girara_file_read

This commit is contained in:
Sebastian Ramacher 2024-01-30 10:24:02 +01:00
parent ba0706d6b9
commit 1598a79039
2 changed files with 12 additions and 15 deletions

View file

@ -159,12 +159,11 @@ zathura_db_read_key_file_from_file(const char* path)
size_t contentlen = strlen(content);
if (contentlen == 0) {
static const char dummy_content[] = "# nothing";
static const size_t dummy_len = sizeof(dummy_content) - 1;
static const size_t dummy_len = sizeof(dummy_content) - 1;
free(content);
content = malloc(sizeof(char) * (dummy_len + 1));
if (content == NULL)
{
g_free(content);
content = g_malloc(sizeof(char) * (dummy_len + 1));
if (content == NULL) {
g_key_file_free(key_file);
return NULL;
}
@ -177,7 +176,7 @@ zathura_db_read_key_file_from_file(const char* path)
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error) ==
FALSE) {
if (error->code != 1) { /* ignore empty file */
free(content);
g_free(content);
g_key_file_free(key_file);
g_error_free(error);
return NULL;
@ -186,7 +185,7 @@ zathura_db_read_key_file_from_file(const char* path)
g_error_free(error);
}
free(content);
g_free(content);
return key_file;
}
@ -759,7 +758,7 @@ plain_io_read(GiraraInputHistoryIO* db)
girara_list_append(res, g_strdup(tmp[i]));
}
g_strfreev(tmp);
free(content);
g_free(content);
return res;
}
@ -785,13 +784,13 @@ plain_io_append(GiraraInputHistoryIO* db, const char* input)
rewind(file);
if (ftruncate(fileno(file), 0) != 0) {
free(content);
g_free(content);
fclose(file);
return;
}
char** tmp = g_strsplit(content, "\n", 0);
free(content);
g_free(content);
/* write input history file */
for (size_t i = 0; tmp[i] != NULL; ++i) {

View file

@ -282,15 +282,13 @@ parse_color(GdkRGBA* color, const char* str)
return true;
}
bool
running_under_wsl(void)
{
bool result = false;
bool running_under_wsl(void) {
bool result = false;
char* content = girara_file_read("/proc/version");
if (content != NULL && g_strstr_len(content, -1, "Microsoft")) {
result = true;
}
free(content);
g_free(content);
return result;
}