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

Function find_or_add_pkg

src/store/store.c:4243–4256  ·  view source on GitHub ↗

Find or insert a package name, returning its index. Returns -1 if full. */

Source from the content-addressed store, hash-verified

4241
4242/* Find or insert a package name, returning its index. Returns -1 if full. */
4243static int find_or_add_pkg(char **all_pkgs, int *npkgs, int max_pkgs, const char *pkg) {
4244 for (int j = 0; j < *npkgs; j++) {
4245 if (strcmp(all_pkgs[j], pkg) == 0) {
4246 return j;
4247 }
4248 }
4249 if (*npkgs < max_pkgs) {
4250 int idx = *npkgs;
4251 all_pkgs[idx] = heap_strdup(pkg);
4252 (*npkgs)++;
4253 return idx;
4254 }
4255 return CBM_NOT_FOUND;
4256}
4257
4258/* Check if a package name appears in an array. */
4259static bool pkg_in_list(const char *pkg, char **list, int count) {

Callers 1

arch_layersFunction · 0.85

Calls 1

heap_strdupFunction · 0.70

Tested by

no test coverage detected