PostGIS  2.3.7dev-r@@SVN_REVISION@@
static void wkt_yyensure_buffer_stack ( void  )
static

Definition at line 1736 of file lwin_wkt_lex.c.

References wkt_yyalloc(), wkt_yyrealloc(), yy_buffer_stack, yy_buffer_stack_max, yy_buffer_stack_top, and YY_FATAL_ERROR.

Referenced by if(), wkt_yy_switch_to_buffer(), wkt_yypush_buffer_state(), and wkt_yyrestart().

1737 {
1738  yy_size_t num_to_alloc;
1739 
1740  if (!(yy_buffer_stack)) {
1741 
1742  /* First allocation is just for 2 elements, since we don't know if this
1743  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1744  * immediate realloc on the next call.
1745  */
1746  num_to_alloc = 1;
1748  (num_to_alloc * sizeof(struct yy_buffer_state*)
1749  );
1750  if ( ! (yy_buffer_stack) )
1751  YY_FATAL_ERROR( "out of dynamic memory in wkt_yyensure_buffer_stack()" );
1752 
1753  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1754 
1755  (yy_buffer_stack_max) = num_to_alloc;
1756  (yy_buffer_stack_top) = 0;
1757  return;
1758  }
1759 
1760  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1761 
1762  /* Increase the buffer to prepare for a possible push. */
1763  int grow_size = 8 /* arbitrary grow size */;
1764 
1765  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1767  ((yy_buffer_stack),
1768  num_to_alloc * sizeof(struct yy_buffer_state*)
1769  );
1770  if ( ! (yy_buffer_stack) )
1771  YY_FATAL_ERROR( "out of dynamic memory in wkt_yyensure_buffer_stack()" );
1772 
1773  /* zero only the new slots.*/
1774  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1775  (yy_buffer_stack_max) = num_to_alloc;
1776  }
1777 }
void * wkt_yyrealloc(void *, yy_size_t)
size_t yy_size_t
Definition: lwin_wkt_lex.c:203
#define YY_FATAL_ERROR(msg)
Definition: lwin_wkt_lex.c:844
static size_t yy_buffer_stack_top
index of top of stack.
Definition: lwin_wkt_lex.c:298
static size_t yy_buffer_stack_max
capacity of stack.
Definition: lwin_wkt_lex.c:299
static YY_BUFFER_STATE * yy_buffer_stack
Stack as an array.
Definition: lwin_wkt_lex.c:300
void * wkt_yyalloc(yy_size_t)

Here is the call graph for this function:

Here is the caller graph for this function: