Allocates the stack if it does not exist. * Guarantees space for at least one push. */
| 1682 | * Guarantees space for at least one push. |
| 1683 | */ |
| 1684 | static void yyensure_buffer_stack (void) |
| 1685 | { |
| 1686 | yy_size_t num_to_alloc; |
| 1687 | |
| 1688 | if (!(yy_buffer_stack)) { |
| 1689 | |
| 1690 | /* First allocation is just for 2 elements, since we don't know if this |
| 1691 | * scanner will even need a stack. We use 2 instead of 1 to avoid an |
| 1692 | * immediate realloc on the next call. |
| 1693 | */ |
| 1694 | num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ |
| 1695 | (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc |
| 1696 | (num_to_alloc * sizeof(struct yy_buffer_state*) |
| 1697 | ); |
| 1698 | if ( ! (yy_buffer_stack) ) |
| 1699 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); |
| 1700 | |
| 1701 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); |
| 1702 | |
| 1703 | (yy_buffer_stack_max) = num_to_alloc; |
| 1704 | (yy_buffer_stack_top) = 0; |
| 1705 | return; |
| 1706 | } |
| 1707 | |
| 1708 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ |
| 1709 | |
| 1710 | /* Increase the buffer to prepare for a possible push. */ |
| 1711 | yy_size_t grow_size = 8 /* arbitrary grow size */; |
| 1712 | |
| 1713 | num_to_alloc = (yy_buffer_stack_max) + grow_size; |
| 1714 | (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc |
| 1715 | ((yy_buffer_stack), |
| 1716 | num_to_alloc * sizeof(struct yy_buffer_state*) |
| 1717 | ); |
| 1718 | if ( ! (yy_buffer_stack) ) |
| 1719 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); |
| 1720 | |
| 1721 | /* zero only the new slots.*/ |
| 1722 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); |
| 1723 | (yy_buffer_stack_max) = num_to_alloc; |
| 1724 | } |
| 1725 | } |
| 1726 | |
| 1727 | /** Setup the input buffer state to scan directly from a user-specified character buffer. |
| 1728 | * @param base the character buffer |
no outgoing calls
no test coverage detected