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

Function cmp_node_ptr_canonical

src/pipeline/pass_configlink.c:80–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78};
79
80static int cmp_node_ptr_canonical(const void *pa, const void *pb) {
81 const cbm_gbuf_node_t *a = *(const cbm_gbuf_node_t *const *)pa;
82 const cbm_gbuf_node_t *b = *(const cbm_gbuf_node_t *const *)pb;
83 const char *qa = a->qualified_name ? a->qualified_name : "";
84 const char *qb = b->qualified_name ? b->qualified_name : "";
85 int r = strcmp(qa, qb);
86 if (r != 0) {
87 return r;
88 }
89 const char *fa = a->file_path ? a->file_path : "";
90 const char *fb = b->file_path ? b->file_path : "";
91 r = strcmp(fa, fb);
92 if (r != 0) {
93 return r;
94 }
95 if (a->start_line != b->start_line) {
96 return a->start_line < b->start_line ? CANON_CMP_LESS : CANON_CMP_GREATER;
97 }
98 const char *na = a->name ? a->name : "";
99 const char *nb = b->name ? b->name : "";
100 return strcmp(na, nb);
101}
102
103/* Heap copy of `nodes` sorted by cmp_node_ptr_canonical. Returns NULL (and
104 * leaves the caller on the unsorted borrowed array) only on allocation

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected