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

Function distinct_list_add

src/cypher/cypher.c:3737–3746  ·  view source on GitHub ↗

Append `val` to a string list only if not already present — i.e. maintain a * set of distinct values. Used by COUNT(DISTINCT x) (#239). */

Source from the content-addressed store, hash-verified

3735/* Append `val` to a string list only if not already present — i.e. maintain a
3736 * set of distinct values. Used by COUNT(DISTINCT x) (#239). */
3737static void distinct_list_add(char ***list, int *count, const char *val) {
3738 for (int i = 0; i < *count; i++) {
3739 if (strcmp((*list)[i], val) == 0) {
3740 return;
3741 }
3742 }
3743 int idx = (*count)++;
3744 *list = safe_realloc(*list, (size_t)(idx + SKIP_ONE) * sizeof(char *));
3745 (*list)[idx] = heap_strdup(val);
3746}
3747
3748/* Sort bindings by the ORDER BY key list (virtual variables) using bubble
3749 * sort; later keys break ties, direction is per key (#1334). */

Callers 2

with_agg_accumulateFunction · 0.85
ret_agg_accumulateFunction · 0.85

Calls 2

safe_reallocFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected