[Tarantool-patches] [PATCH 3/5] journal: add journal_entry_create helper
Cyrill Gorcunov
gorcunov at gmail.com
Wed Jul 22 18:33:57 MSK 2020
To create raw journal entries.
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
src/box/journal.c | 8 ++------
src/box/journal.h | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/box/journal.c b/src/box/journal.c
index fb81acb39..159e32ff3 100644
--- a/src/box/journal.c
+++ b/src/box/journal.c
@@ -51,11 +51,7 @@ journal_entry_new(size_t n_rows, struct region *region,
return NULL;
}
- entry->write_async_cb = write_async_cb;
- entry->complete_data = complete_data;
- entry->approx_len = 0;
- entry->n_rows = n_rows;
- entry->res = -1;
-
+ journal_entry_create(entry, n_rows, 0, write_async_cb,
+ complete_data);
return entry;
}
diff --git a/src/box/journal.h b/src/box/journal.h
index 74a5eb050..6e1160ad8 100644
--- a/src/box/journal.h
+++ b/src/box/journal.h
@@ -80,6 +80,26 @@ struct journal_entry {
struct region;
+/**
+ * Initialize a new journal entry.
+ */
+static inline void
+journal_entry_create(struct journal_entry *entry, size_t n_rows,
+ size_t approx_len,
+ void (*write_async_cb)(struct journal_entry *entry),
+ void *complete_data)
+{
+ /*
+ * fifo member is set untouched since it is for
+ * an internal use of a journal engine.
+ */
+ entry->write_async_cb = write_async_cb;
+ entry->complete_data = complete_data;
+ entry->approx_len = approx_len;
+ entry->n_rows = n_rows;
+ entry->res = -1;
+}
+
/**
* Create a new journal entry.
*
--
2.26.2
More information about the Tarantool-patches
mailing list