Chain every type and function into its name's list, and collect the * namespace roots. */
| 327 | /* Chain every type and function into its name's list, and collect the |
| 328 | * namespace roots. */ |
| 329 | static bool pr_link(pr_index_t *ix) { |
| 330 | ix->type_at = cbm_ht_create_in(CBM_MEM_CLASS_OTHER, (uint32_t)(ix->ntypes + SKIP_ONE)); |
| 331 | ix->func_at = cbm_ht_create_in(CBM_MEM_CLASS_OTHER, (uint32_t)(ix->nfuncs + SKIP_ONE)); |
| 332 | ix->roots = cbm_ht_create_in(CBM_MEM_CLASS_OTHER, CBM_SZ_64); |
| 333 | if (!ix->type_at || !ix->func_at || !ix->roots) { |
| 334 | return false; |
| 335 | } |
| 336 | for (int i = 0; i < ix->ntypes && !ix->oom; i++) { |
| 337 | pr_type_t *t = &ix->types[i]; |
| 338 | const char *key = t->fqn ? pr_lower(ix, t->fqn, strlen(t->fqn)) : NULL; |
| 339 | if (!key) { |
| 340 | continue; |
| 341 | } |
| 342 | void *prev = cbm_ht_get(ix->type_at, key); |
| 343 | t->next = prev ? (int)((uintptr_t)prev - SKIP_ONE) : CBM_NOT_FOUND; |
| 344 | cbm_ht_set(ix->type_at, key, (void *)(uintptr_t)(i + SKIP_ONE)); |
| 345 | if (strchr(t->fqn, '\\')) { |
| 346 | pr_add_root(ix, t->fqn); |
| 347 | } |
| 348 | } |
| 349 | for (int i = 0; i < ix->nfuncs && !ix->oom; i++) { |
| 350 | pr_func_t *fn = &ix->funcs[i]; |
| 351 | const char *key = fn->fqn ? pr_lower(ix, fn->fqn, strlen(fn->fqn)) : NULL; |
| 352 | if (!key) { |
| 353 | continue; |
| 354 | } |
| 355 | void *prev = cbm_ht_get(ix->func_at, key); |
| 356 | fn->next = prev ? (int)((uintptr_t)prev - SKIP_ONE) : CBM_NOT_FOUND; |
| 357 | cbm_ht_set(ix->func_at, key, (void *)(uintptr_t)(i + SKIP_ONE)); |
| 358 | if (strchr(fn->fqn, '\\')) { |
| 359 | pr_add_root(ix, fn->fqn); |
| 360 | } |
| 361 | } |
| 362 | for (int i = 0; i < ix->nfiles && !ix->oom; i++) { |
| 363 | for (int k = 0; k < ix->files[i].nnss; k++) { |
| 364 | pr_add_root(ix, ix->files[i].nss[k].name); |
| 365 | } |
| 366 | } |
| 367 | return !ix->oom; |
| 368 | } |
| 369 | |
| 370 | static void *pr_build(const cbm_doclink_build_in_t *in) { |
| 371 | pr_index_t *ix = (pr_index_t *)cbm_calloc(CBM_MEM_CLASS_OTHER, sizeof(*ix)); |
no test coverage detected