Append `pkg` to a distinct package list (with a per-package count). */
| 5210 | |
| 5211 | /* Append `pkg` to a distinct package list (with a per-package count). */ |
| 5212 | static void cluster_add_pkg(const char **pkgs, int *counts, int *count, int cap, const char *pkg) { |
| 5213 | if (!pkg || !pkg[0]) { |
| 5214 | return; |
| 5215 | } |
| 5216 | for (int i = 0; i < *count; i++) { |
| 5217 | if (strcmp(pkgs[i], pkg) == 0) { |
| 5218 | counts[i]++; |
| 5219 | return; |
| 5220 | } |
| 5221 | } |
| 5222 | if (*count < cap) { |
| 5223 | pkgs[*count] = heap_strdup(pkg); |
| 5224 | counts[*count] = 1; |
| 5225 | (*count)++; |
| 5226 | } |
| 5227 | } |
| 5228 | |
| 5229 | /* Build the cluster_info for one community c into *ci. */ |
| 5230 | static void cluster_build_one(cbm_cluster_info_t *ci, int c, int n, const int *comm, |
no test coverage detected