Find or insert a package name, returning its index. Returns -1 if full. */
| 4241 | |
| 4242 | /* Find or insert a package name, returning its index. Returns -1 if full. */ |
| 4243 | static 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. */ |
| 4259 | static bool pkg_in_list(const char *pkg, char **list, int count) { |
no test coverage detected