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

Function gf_inventory_compare

src/mcp/test_impact_git.c:1165–1184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1163}
1164
1165static bool gf_inventory_compare(cbm_git_facts_t *facts, const cbm_git_tree_entry_t *a,
1166 const cbm_git_tree_entry_t *b, int *comparison,
1167 cbm_git_facts_error_t *error) {
1168 size_t common = a->path_length < b->path_length ? a->path_length : b->path_length;
1169 for (size_t at = 0; at < common;) {
1170 if (!gf_gate(facts, error))
1171 return false;
1172 size_t chunk = common - at;
1173 if (chunk > 65536)
1174 chunk = 65536;
1175 int cmp = memcmp(a->path + at, b->path + at, chunk);
1176 if (cmp) {
1177 *comparison = cmp < 0 ? -1 : 1;
1178 return true;
1179 }
1180 at += chunk;
1181 }
1182 *comparison = a->path_length < b->path_length ? -1 : a->path_length > b->path_length ? 1 : 0;
1183 return true;
1184}
1185
1186/* In-place heapsort: deterministic byte order, no recursive stack or hidden
1187 * allocation, and request gates during comparisons and each extraction. */

Callers 2

gf_inventory_siftFunction · 0.85
gf_inventory_sortFunction · 0.85

Calls 1

gf_gateFunction · 0.85

Tested by

no test coverage detected