| 2514 | } |
| 2515 | |
| 2516 | static CBMHashTable *doc_code_dirs(const doc_files_t *df) { |
| 2517 | CBMHashTable *dirs = cbm_ht_create_in(CBM_MEM_CLASS_SEMANTIC, CBM_SZ_256); |
| 2518 | for (int i = 0; dirs && i < df->count; i++) { |
| 2519 | const char *path = df->node[i]->file_path; |
| 2520 | if (df->off[i + SKIP_ONE] == df->off[i]) { |
| 2521 | continue; |
| 2522 | } |
| 2523 | for (const char *p = strchr(path, '/'); p; p = strchr(p + SKIP_ONE, '/')) { |
| 2524 | size_t n = (size_t)(p - path); |
| 2525 | char *key = cbm_alloc(CBM_MEM_CLASS_SEMANTIC, n + SKIP_ONE); |
| 2526 | if (!key) { |
| 2527 | doc_code_dirs_free(dirs); |
| 2528 | return NULL; |
| 2529 | } |
| 2530 | memcpy(key, path, n); |
| 2531 | key[n] = '\0'; |
| 2532 | if (cbm_ht_has(dirs, key)) { |
| 2533 | cbm_free(CBM_MEM_CLASS_SEMANTIC, key); |
| 2534 | } else { |
| 2535 | cbm_ht_set(dirs, key, (void *)(intptr_t)SKIP_ONE); |
| 2536 | } |
| 2537 | } |
| 2538 | } |
| 2539 | return dirs; |
| 2540 | } |
| 2541 | |
| 2542 | /* A candidate's position: inside the home (or the home folder itself), |
| 2543 | * outside it, or no position (the home is the repository root). */ |
no test coverage detected