| 397 | enum { DOCLINK_INIT_CAP = 16 }; |
| 398 | |
| 399 | void cbm_doclinks_push(CBMDocLinkArray *arr, CBMArena *a, CBMDocLink link) { |
| 400 | if (arr->count >= arr->cap) { |
| 401 | int ncap = arr->cap ? arr->cap * PAIR_LEN : DOCLINK_INIT_CAP; |
| 402 | CBMDocLink *grown; |
| 403 | #if defined(CBM_ENABLE_TEST_SEAMS) && CBM_ENABLE_TEST_SEAMS |
| 404 | if (cbm_doclink_test_fail_alloc(CBM_DOCLINK_ALLOC_TOKENS)) { |
| 405 | grown = NULL; |
| 406 | } else |
| 407 | #endif |
| 408 | { |
| 409 | grown = (CBMDocLink *)cbm_arena_alloc(a, (size_t)ncap * sizeof(*grown)); |
| 410 | } |
| 411 | if (!grown) { |
| 412 | arr->failed = true; /* the token is lost: the layer must not say ok */ |
| 413 | return; |
| 414 | } |
| 415 | if (arr->count > 0) { |
| 416 | memcpy(grown, arr->items, (size_t)arr->count * sizeof(*grown)); |
| 417 | } |
| 418 | arr->items = grown; |
| 419 | arr->cap = ncap; |
| 420 | } |
| 421 | arr->items[arr->count++] = link; |
| 422 | } |
| 423 | |
| 424 | typedef struct { |
| 425 | uint32_t line; |
no test coverage detected