Skip to content

Commit

Permalink
Guard breaking changes with DQLITE_NEXT
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Miller <[email protected]>
  • Loading branch information
cole-miller committed Apr 25, 2024
1 parent 12d2eed commit d80c8ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/raft/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ void entryBatchesDestroy(struct raft_entry *entries, const size_t n, bool with_l
}
assert(n > 0);
for (i = 0; i < n; i++) {
#ifdef DQLITE_NEXT
if (with_local_bufs) {
raft_free(entries[i].local_buf.base);
}
#else
(void)with_local_bufs;
#endif
assert(entries[i].batch != NULL);
if (entries[i].batch != batch) {
batch = entries[i].batch;
Expand All @@ -31,6 +35,7 @@ int entryCopy(const struct raft_entry *src, struct raft_entry *dst, bool with_lo
dst->term = src->term;
dst->type = src->type;

#ifdef DQLITE_NEXT
if (with_local_buf) {
dst->local_buf.len = src->local_buf.len;
dst->local_buf.base = raft_malloc(dst->local_buf.len);
Expand All @@ -43,6 +48,9 @@ int entryCopy(const struct raft_entry *src, struct raft_entry *dst, bool with_lo
} else {
dst->local_buf = (struct raft_buffer){};
}
#else
(void)with_local_buf;
#endif

dst->buf.len = src->buf.len;
dst->buf.base = raft_malloc(dst->buf.len);
Expand Down Expand Up @@ -95,6 +103,7 @@ int entryBatchCopy(const struct raft_entry *src,
out[i].term = src[i].term;
out[i].type = src[i].type;

#ifdef DQLITE_NEXT
if (with_local_bufs) {
out[i].local_buf.len = src[i].local_buf.len;
out[i].local_buf.base = raft_malloc(out[i].local_buf.len);
Expand All @@ -107,6 +116,9 @@ int entryBatchCopy(const struct raft_entry *src,
} else {
out[i].local_buf = (struct raft_buffer){};
}
#else
(void)with_local_bufs;
#endif

out[i].buf.base = cursor;
out[i].buf.len = src[i].buf.len;
Expand Down

0 comments on commit d80c8ca

Please sign in to comment.