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

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

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

Here is the call graph for this function:

Here is the caller graph for this function: