MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / rec_total_header

Function rec_total_header

internal/cbm/sqlite_writer.c:435–447  ·  view source on GitHub ↗

Finalize: returns the complete record bytes (header_len + header + body). Caller must free the returned buffer.

Source from the content-addressed store, hash-verified

433// Finalize: returns the complete record bytes (header_len + header + body).
434// Caller must free the returned buffer.
435static int rec_total_header(const RecordBuilder *r) {
436 int header_content_len = r->header.len;
437 int header_len_varint_len = varint_len(header_content_len + varint_len(header_content_len));
438 // The header size varint includes itself, so we may need to iterate
439 int total_header = header_len_varint_len + header_content_len;
440 // Check if the header_len varint changes size when it includes itself
441 int recalc = varint_len(total_header);
442 if (recalc != header_len_varint_len) {
443 header_len_varint_len = recalc;
444 total_header = header_len_varint_len + header_content_len;
445 }
446 return total_header;
447}
448
449// Bytes rec_write produces: the record exactly as rec_finalize returns it.
450static int rec_payload_len(const RecordBuilder *r) {

Callers 2

rec_payload_lenFunction · 0.85
rec_writeFunction · 0.85

Calls 1

varint_lenFunction · 0.85

Tested by

no test coverage detected