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

Definition at line 1711 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().

1712 {
1713  yy_size_t num_to_alloc;
1714 
1715  if (!(yy_buffer_stack)) {
1716 
1717  /* First allocation is just for 2 elements, since we don't know if this
1718  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1719  * immediate realloc on the next call.
1720  */
1721  num_to_alloc = 1;
1723  (num_to_alloc * sizeof(struct yy_buffer_state*)
1724  );
1725  if ( ! (yy_buffer_stack) )
1726  YY_FATAL_ERROR( "out of dynamic memory in wkt_yyensure_buffer_stack()" );
1727 
1728  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1729 
1730  (yy_buffer_stack_max) = num_to_alloc;
1731  (yy_buffer_stack_top) = 0;
1732  return;
1733  }
1734 
1735  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1736 
1737  /* Increase the buffer to prepare for a possible push. */
1738  int grow_size = 8 /* arbitrary grow size */;
1739 
1740  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1742  ((yy_buffer_stack),
1743  num_to_alloc * sizeof(struct yy_buffer_state*)
1744  );
1745  if ( ! (yy_buffer_stack) )
1746  YY_FATAL_ERROR( "out of dynamic memory in wkt_yyensure_buffer_stack()" );
1747 
1748  /* zero only the new slots.*/
1749  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1750  (yy_buffer_stack_max) = num_to_alloc;
1751  }
1752 }
void * wkt_yyrealloc(void *, yy_size_t)
size_t yy_size_t
Definition: lwin_wkt_lex.c:178
#define YY_FATAL_ERROR(msg)
Definition: lwin_wkt_lex.c:819
static size_t yy_buffer_stack_top
index of top of stack.
Definition: lwin_wkt_lex.c:273
static size_t yy_buffer_stack_max
capacity of stack.
Definition: lwin_wkt_lex.c:274
static YY_BUFFER_STATE * yy_buffer_stack
Stack as an array.
Definition: lwin_wkt_lex.c:275
void * wkt_yyalloc(yy_size_t)

Here is the call graph for this function:

Here is the caller graph for this function: