| 758 | } tm_invocation_t; |
| 759 | |
| 760 | static bool tm_argument_append(tm_invocation_t *invocation, const tm_argument_t *arg) { |
| 761 | if (invocation->count == invocation->cap) { |
| 762 | if (invocation->cap > INT_MAX / 2) |
| 763 | return false; |
| 764 | int cap = invocation->cap ? invocation->cap * 2 : 8; |
| 765 | if ((size_t)cap > SIZE_MAX / sizeof(*invocation->args)) |
| 766 | return false; |
| 767 | tm_argument_t *args = cbm_arena_alloc(&invocation->arena, (size_t)cap * sizeof(*args)); |
| 768 | if (!args) |
| 769 | return false; |
| 770 | if (invocation->count) |
| 771 | memcpy(args, invocation->args, (size_t)invocation->count * sizeof(*args)); |
| 772 | invocation->args = args; |
| 773 | invocation->cap = cap; |
| 774 | } |
| 775 | invocation->args[invocation->count++] = *arg; |
| 776 | return true; |
| 777 | } |
| 778 | |
| 779 | /* C macro argument commas are shielded by parentheses, not by brackets, |
| 780 | * braces or template angle brackets. The lexer handles comments and ordinary |
no test coverage detected