You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto base_ptr = buffer->preamble() + (buffer->preamble_bytes() - total_hdr_size);
277
+
util::check(buffer->data() != nullptr, "Unexpected null base pointer in v1 header serialization");
275
278
util::check(base_ptr + total_hdr_size == buffer->data(), "Expected base ptr to align with data ptr, {} != {}",fmt::ptr(base_ptr + total_hdr_size),fmt::ptr(buffer->data()));
276
-
write_proto_header(base_ptr);
277
-
ARCTICDB_TRACE(log::storage(), "Header fits in internal buffer {:x} with {} bytes space: {}", intptr_t (base_ptr), buffer->preamble_bytes() - total_hdr_size,dump_bytes(buffer->data(), buffer->bytes(), 100u));
279
+
auto red_zone = *buffer->data();
280
+
auto header_bytes_written = write_proto_header(base_ptr, hdr_size);
281
+
ARCTICDB_TRACE(log::storage(), "Header fits in internal buffer {:x} with {} bytes space: {}", intptr_t (base_ptr), buffer->preamble_bytes() - total_hdr_size,dump_bytes(buffer->data(), buffer->bytes(), 10u));
"Buffer available space {} is less than required size {}",
292
-
tmp->available(),
293
-
total_size);
294
295
295
-
// This is both a sanity check and a way to populate the segment with the correct size
296
+
util::check(tmp->available() >= total_size, "Buffer available space {} is less than required size {}",tmp->available(), total_size);
297
+
296
298
auto calculated_size = calculate_size();
297
299
util::check(total_size == calculated_size, "Expected total size {} to be equal to calculated size {}", total_size, calculated_size);
298
300
299
301
auto* dst = tmp->preamble();
300
302
util::check(dst != nullptr, "Expected dst to be non-null");
303
+
auto header_bytes_written = write_proto_header(dst, hdr_size);
301
304
302
-
auto written_hdr_size = write_proto_header(dst);
303
-
util::check(written_hdr_size == hdr_size, "Expected written header size {} to be equal to expected header size {}", written_hdr_size, hdr_size);
305
+
// This is a bit redundant since the size is also checked in write_proto_header, but the consequences of getting
306
+
// it wrong are pretty bad (corrupt data) so will leave it in for future-proofing
307
+
util::check(header_bytes_written == hdr_size, "Expected written header size {} to be equal to expected header size {}", header_bytes_written, hdr_size);
0 commit comments