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

Function pp_props_buf

src/pipeline/pass_parallel.c:739–760  ·  view source on GitHub ↗

A def's properties buffer: CBM_SZ_2K for every other field plus the whole * serialized docstring, variants and variant_key fields, which have no length * cap (a field that does not fit is dropped whole). Returns `stack` for a def * with none of them, or when the larger buffer cannot be allocated. Twin of * pass_definitions.c -- keep both in sync. */

Source from the content-addressed store, hash-verified

737 * with none of them, or when the larger buffer cannot be allocated. Twin of
738 * pass_definitions.c -- keep both in sync. */
739static char *pp_props_buf(const CBMDefinition *def, char *stack, size_t *size) {
740 size_t need = *size;
741 if (def->docstring && def->docstring[0]) {
742 need += strlen("docstring") + pp_json_escaped_len(def->docstring) + PP_JSON_FIELD_OVERHEAD;
743 }
744 if (def->variants && def->variants[0]) {
745 need += strlen("variants") + strlen(def->variants) + PP_JSON_FIELD_OVERHEAD;
746 }
747 if (def->variant_key && def->variant_key[0]) {
748 need +=
749 strlen("variant_key") + pp_json_escaped_len(def->variant_key) + PP_JSON_FIELD_OVERHEAD;
750 }
751 if (need == *size) {
752 return stack;
753 }
754 char *buf = cbm_alloc(CBM_MEM_CLASS_GBUF_STRING, need);
755 if (!buf) {
756 return stack;
757 }
758 *size = need;
759 return buf;
760}
761
762/* Insert one definition node (and its route if present) into the local gbuf. */
763static void insert_def_into_gbuf(extract_worker_state_t *ws, const cbm_stem_marks_t *marks,

Callers 1

insert_def_into_gbufFunction · 0.85

Calls 2

pp_json_escaped_lenFunction · 0.85
cbm_allocFunction · 0.85

Tested by

no test coverage detected