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

Function sig_capped

internal/cbm/callable_sig.c:901–933  ·  view source on GitHub ↗

"(" leading whole entries ")" ... "# )" within CBM_CALLABLE_SIG_MAX. */

Source from the content-addressed store, hash-verified

899
900/* "(" leading whole entries ")" ... "#<hash>)" within CBM_CALLABLE_SIG_MAX. */
901static const char *sig_capped(CBMArena *a, const sig_ctx_t *c, const char *full, size_t n) {
902 char tail[SIG_CAPPED_TAIL + 1];
903 snprintf(tail, sizeof(tail), "#%016llx)", (unsigned long long)sig_fnv64(full, n));
904 size_t keep = 0; /* bytes of entry text after the "(" */
905 bool comma = sig_writes_types(c);
906 int limit = c->too_many ? SIG_MAX_ENTRIES : c->entries;
907 for (int i = 0; i < limit; i++) {
908 size_t end = c->entry_end[i];
909 if (end < c->open_off + 1 || end > c->close_off) {
910 break;
911 }
912 size_t candidate = end - (c->open_off + 1);
913 if (1 + candidate + (comma ? 1 : 0) + SIG_CAPPED_TAIL > CBM_CALLABLE_SIG_MAX) {
914 break;
915 }
916 keep = candidate;
917 }
918 char *out = cbm_arena_alloc(a, CBM_CALLABLE_SIG_MAX + 1);
919 if (!out) {
920 return NULL;
921 }
922 size_t len = 0;
923 out[len++] = '(';
924 memcpy(out + len, c->buf + c->open_off + 1, keep);
925 len += keep;
926 if (keep && comma) {
927 out[len++] = ',';
928 }
929 memcpy(out + len, tail, SIG_CAPPED_TAIL);
930 len += SIG_CAPPED_TAIL;
931 out[len] = '\0';
932 return out;
933}
934
935/* ── Builder ───────────────────────────────────────────────────── */
936

Callers 1

cbm_callable_sig_modeFunction · 0.85

Calls 3

sig_fnv64Function · 0.85
sig_writes_typesFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected