group -> the package directories that declare it (owned keys and lists); * `seen` holds "group\x1fdir" (owned keys) so a repeat is one lookup. */
| 671 | /* group -> the package directories that declare it (owned keys and lists); |
| 672 | * `seen` holds "group\x1fdir" (owned keys) so a repeat is one lookup. */ |
| 673 | static void op_note_group(CBMHashTable *groups, CBMHashTable *seen, const char *group, |
| 674 | const char *dir) { |
| 675 | char key[PAIR_LEN * CBM_SZ_1K]; |
| 676 | op_key(key, sizeof(key), group, dir); |
| 677 | if (!group[0] || cbm_ht_get(seen, key)) { |
| 678 | return; |
| 679 | } |
| 680 | char *seen_key = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, key); |
| 681 | if (!seen_key) { |
| 682 | return; |
| 683 | } |
| 684 | cbm_ht_set(seen, seen_key, seen_key); |
| 685 | op_strs_t *dirs = cbm_ht_get(groups, group); |
| 686 | if (!dirs) { |
| 687 | dirs = cbm_calloc(CBM_MEM_CLASS_OTHER, sizeof(*dirs)); |
| 688 | char *gkey = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, group); |
| 689 | if (!dirs || !gkey) { |
| 690 | cbm_free(CBM_MEM_CLASS_OTHER, dirs); |
| 691 | cbm_free(CBM_MEM_CLASS_OTHER, gkey); |
| 692 | return; |
| 693 | } |
| 694 | cbm_ht_set(groups, gkey, dirs); |
| 695 | } |
| 696 | op_strs_push(dirs, dir); |
| 697 | } |
| 698 | |
| 699 | static void op_scan_groups(CBMHashTable *groups, CBMHashTable *seen, const char *file, |
| 700 | const char *text) { |
no test coverage detected