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

Function chain_query

tests/test_cypher.c:5248–5266  ·  view source on GitHub ↗

head + "f.name \"v0\"" + join + "f.name \"v1\"" + ... + tail */

Source from the content-addressed store, hash-verified

5246
5247/* head + "f.name <op> \"v0\"" + join + "f.name <op> \"v1\"" + ... + tail */
5248static char *chain_query(const char *head, const char *op, const char *join, const char *tail) {
5249 size_t cap = 256 + (size_t)CYPHER_CHAIN_OPERANDS * 64;
5250 char *q = malloc(cap);
5251 if (!q) {
5252 return NULL;
5253 }
5254 size_t len = (size_t)snprintf(q, cap, "%s", head);
5255 for (int i = 0; i < CYPHER_CHAIN_OPERANDS && len < cap; i++) {
5256 char buf[48];
5257 const char *v = chain_operand_value(i, buf, sizeof(buf));
5258 len += (size_t)snprintf(q + len, cap - len, "%sf.name %s \"%s\"", i ? join : "", op, v);
5259 }
5260 if (len >= cap) {
5261 free(q);
5262 return NULL;
5263 }
5264 snprintf(q + len, cap - len, "%s", tail);
5265 return q;
5266}
5267
5268typedef struct {
5269 const char *head;

Callers 1

chain_checkFunction · 0.85

Calls 1

chain_operand_valueFunction · 0.85

Tested by

no test coverage detected