Append `pkg` to a distinct package list (with a per-package count). */
| 10517 | |
| 10518 | /* Append `pkg` to a distinct package list (with a per-package count). */ |
| 10519 | static void cluster_add_pkg(const char **pkgs, int *counts, int *count, int cap, const char *pkg) { |
| 10520 | if (!pkg || !pkg[0]) { |
| 10521 | return; |
| 10522 | } |
| 10523 | for (int i = 0; i < *count; i++) { |
| 10524 | if (strcmp(pkgs[i], pkg) == 0) { |
| 10525 | counts[i]++; |
| 10526 | return; |
| 10527 | } |
| 10528 | } |
| 10529 | if (*count < cap) { |
| 10530 | pkgs[*count] = heap_strdup(pkg); |
| 10531 | counts[*count] = 1; |
| 10532 | (*count)++; |
| 10533 | } |
| 10534 | } |
| 10535 | |
| 10536 | /* Build the cluster_info for one community c into *ci. */ |
| 10537 | static void cluster_build_one(cbm_cluster_info_t *ci, int c, int n, const int *comm, |
no test coverage detected