| 2599 | } |
| 2600 | |
| 2601 | FORCE_INLINE |
| 2602 | void concat_word(char* out_buf, int* out_idx, const char* in_buf, int in_len, |
| 2603 | bool in_validity, const char* separator, int separator_len, |
| 2604 | bool* seenAnyValidInput) { |
| 2605 | if (!in_validity) { |
| 2606 | return; |
| 2607 | } |
| 2608 | |
| 2609 | // input is valid |
| 2610 | if (*seenAnyValidInput) { |
| 2611 | // copy the separator and update *out_idx |
| 2612 | memcpy(out_buf + *out_idx, separator, separator_len); |
| 2613 | *out_idx += separator_len; |
| 2614 | } |
| 2615 | // copy the input and update *out_idx |
| 2616 | memcpy(out_buf + *out_idx, in_buf, in_len); |
| 2617 | *seenAnyValidInput = true; |
| 2618 | *out_idx += in_len; |
| 2619 | } |
| 2620 | |
| 2621 | // Helper structure to maintain state during safe length accumulation |
| 2622 | struct SafeLengthState { |