diff --git a/lib/include/edapi/journal/entry.h b/lib/include/edapi/journal/entry.h index e671941..fc2b2b2 100644 --- a/lib/include/edapi/journal/entry.h +++ b/lib/include/edapi/journal/entry.h @@ -21,6 +21,8 @@ G_DECLARE_DERIVABLE_TYPE( EDJournalEntry *ed_journal_entry_new(void); +EDJournalEntry *ed_journal_entry_new_parse(gchar const *line, GError **error); + EDErrorCode ed_journal_entry_parse(EDJournalEntry *self, gchar const *line, GError **error); diff --git a/lib/src/journal/entry.c b/lib/src/journal/entry.c index 359b602..b6feed2 100644 --- a/lib/src/journal/entry.c +++ b/lib/src/journal/entry.c @@ -45,6 +45,22 @@ EDJournalEntry *ed_journal_entry_new(void) ); } +EDJournalEntry *ed_journal_entry_new_parse(gchar const *line, GError **error) +{ + EDJournalEntry *e = ed_journal_entry_new(); + return_if_true(e == NULL, NULL); + + EDErrorCode ret = ed_error_internal; + + ret = ed_journal_entry_parse(e, line, error); + if (ED_ERROR(ret)) { + g_clear_object(&e); + return NULL; + } + + return e; +} + EDErrorCode ed_journal_entry_parse(EDJournalEntry *self, gchar const *line, GError **error) diff --git a/lib/src/journal/file.c b/lib/src/journal/file.c index 3c1d363..f86619e 100644 --- a/lib/src/journal/file.c +++ b/lib/src/journal/file.c @@ -252,11 +252,9 @@ static EDErrorCode ed_journal_file_load(EDJournalFile *self, linelen = 0; } - entry = ed_journal_entry_new(); + entry = ed_journal_entry_new_parse(line, NULL); goto_if_true(entry == NULL, done); - ret = ed_journal_entry_parse(entry, line, NULL); - g_free(line); line = NULL; linelen = 0;