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

Function doc_links_sample_string

src/mcp/mcp.c:6364–6387  ·  view source on GitHub ↗

The seam rejects an actual sample string allocation in yyjson's pool, * independently of when that pool needs another backing allocation. */

Source from the content-addressed store, hash-verified

6362/* The seam rejects an actual sample string allocation in yyjson's pool,
6363 * independently of when that pool needs another backing allocation. */
6364static yyjson_mut_val *doc_links_sample_string(yyjson_mut_doc *doc, const char *source,
6365 size_t length) {
6366 if (!doc || !source) {
6367 return NULL;
6368 }
6369#ifdef CBM_ENABLE_TEST_SEAMS
6370 int remaining =
6371 atomic_load_explicit(&mcp_doc_links_sample_alloc_countdown, memory_order_relaxed);
6372 while (remaining >= 0) {
6373 int next = remaining == 0 ? CBM_NOT_FOUND : remaining - 1;
6374 if (atomic_compare_exchange_weak_explicit(&mcp_doc_links_sample_alloc_countdown, &remaining,
6375 next, memory_order_relaxed,
6376 memory_order_relaxed)) {
6377 if (remaining == 0) {
6378 atomic_store_explicit(&mcp_doc_links_sample_alloc_failed, true,
6379 memory_order_relaxed);
6380 return NULL;
6381 }
6382 break;
6383 }
6384 }
6385#endif
6386 return yyjson_mut_strncpy(doc, source, length);
6387}
6388
6389typedef struct {
6390 char text[CBM_DOC_LINK_PREVIEW_LONG_BYTES + 1];

Callers 1

doc_link_preview_samplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected