| 348 | static int cbm_initialized = 0; |
| 349 | |
| 350 | int cbm_init(void) { |
| 351 | if (cbm_initialized) { |
| 352 | return 0; |
| 353 | } |
| 354 | enum { CBM_INIT_DONE = 1 }; |
| 355 | cbm_initialized = CBM_INIT_DONE; |
| 356 | /* Defense-in-depth allocator binds (idempotent). main() calls cbm_alloc_init |
| 357 | * first; this covers non-main entry points (pipeline passes call cbm_init). |
| 358 | * For sqlite the SQLITE_CONFIG_MALLOC bind only takes effect if it runs |
| 359 | * before sqlite initializes — main() guarantees that ordering; here it is a |
| 360 | * best-effort idempotent re-assert for paths that never hit main(). */ |
| 361 | cbm_alloc_init(); |
| 362 | return 0; |
| 363 | } |
| 364 | |
| 365 | void cbm_reset_thread_parser(void) { |
| 366 | // Release parser's internal slab-allocated subtrees (stack, cached token). |