| 434 | /* ── Lifecycle ──────────────────────────────────────────────────── */ |
| 435 | |
| 436 | cbm_gbuf_t *cbm_gbuf_new(const char *project, const char *root_path) { |
| 437 | cbm_gbuf_t *gb = calloc(CBM_ALLOC_ONE, sizeof(cbm_gbuf_t)); |
| 438 | if (!gb) { |
| 439 | return NULL; |
| 440 | } |
| 441 | |
| 442 | gb->project = strdup(project ? project : ""); |
| 443 | gb->root_path = strdup(root_path ? root_path : ""); |
| 444 | gb->next_id = SKIP_ONE; |
| 445 | gb->shared_ids = NULL; |
| 446 | |
| 447 | gb->node_by_qn = cbm_ht_create(CBM_SZ_256); |
| 448 | gb->by_id = NULL; |
| 449 | gb->by_id_cap = 0; |
| 450 | gb->nodes_by_label = cbm_ht_create(CBM_SZ_32); |
| 451 | gb->nodes_by_name = cbm_ht_create(CBM_SZ_256); |
| 452 | |
| 453 | gb->edge_by_key = cbm_ht_create(CBM_SZ_512); |
| 454 | gb->edges_by_source_type = cbm_ht_create(CBM_SZ_256); |
| 455 | gb->edges_by_target_type = cbm_ht_create(CBM_SZ_256); |
| 456 | gb->edges_by_type = cbm_ht_create(CBM_SZ_32); |
| 457 | |
| 458 | gb->intern_pool = cbm_ht_create(CBM_SZ_1K); |
| 459 | |
| 460 | return gb; |
| 461 | } |
| 462 | |
| 463 | cbm_gbuf_t *cbm_gbuf_new_shared_ids(const char *project, const char *root_path, |
| 464 | _Atomic int64_t *id_source) { |