MCPcopy Create free account
hub / github.com/Entware/Entware / yyensure_buffer_stack

Function yyensure_buffer_stack

scripts/config/lexer.lex.c:3606–3647  ·  view source on GitHub ↗

Allocates the stack if it does not exist. * Guarantees space for at least one push. */

Source from the content-addressed store, hash-verified

3604 * Guarantees space for at least one push.
3605 */
3606static void yyensure_buffer_stack (void)
3607{
3608 yy_size_t num_to_alloc;
3609
3610 if (!(yy_buffer_stack)) {
3611
3612 /* First allocation is just for 2 elements, since we don't know if this
3613 * scanner will even need a stack. We use 2 instead of 1 to avoid an
3614 * immediate realloc on the next call.
3615 */
3616 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
3617 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
3618 (num_to_alloc * sizeof(struct yy_buffer_state*)
3619 );
3620 if ( ! (yy_buffer_stack) )
3621 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
3622
3623 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3624
3625 (yy_buffer_stack_max) = num_to_alloc;
3626 (yy_buffer_stack_top) = 0;
3627 return;
3628 }
3629
3630 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
3631
3632 /* Increase the buffer to prepare for a possible push. */
3633 yy_size_t grow_size = 8 /* arbitrary grow size */;
3634
3635 num_to_alloc = (yy_buffer_stack_max) + grow_size;
3636 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
3637 ((yy_buffer_stack),
3638 num_to_alloc * sizeof(struct yy_buffer_state*)
3639 );
3640 if ( ! (yy_buffer_stack) )
3641 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
3642
3643 /* zero only the new slots.*/
3644 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
3645 (yy_buffer_stack_max) = num_to_alloc;
3646 }
3647}
3648
3649/** Setup the input buffer state to scan directly from a user-specified character buffer.
3650 * @param base the character buffer

Callers 4

lexer.lex.cFile · 0.85
yyrestartFunction · 0.85
yy_switch_to_bufferFunction · 0.85
yypush_buffer_stateFunction · 0.85

Calls 2

yyallocFunction · 0.85
yyreallocFunction · 0.85

Tested by

no test coverage detected