Fixed prefix issues with memory functions.
%*
%c
-void *yy_flex_alloc YY_PROTO(( yy_size_t YY_LAST_ARG ));
-void *yy_flex_realloc YY_PROTO(( void *, yy_size_t YY_LAST_ARG ));
-void yy_flex_free YY_PROTO(( void * YY_LAST_ARG ));
+void *yyalloc YY_PROTO(( yy_size_t YY_LAST_ARG ));
+void *yyrealloc YY_PROTO(( void *, yy_size_t YY_LAST_ARG ));
+void yyfree YY_PROTO(( void * YY_LAST_ARG ));
%e
#define yy_new_buffer yy_create_buffer
yyFlexLexer::~yyFlexLexer()
{
delete [] yy_state_buf;
- yy_flex_free( yy_start_stack YY_CALL_LAST_ARG );
+ yyfree( yy_start_stack YY_CALL_LAST_ARG );
yy_delete_buffer( yy_current_buffer YY_CALL_LAST_ARG);
}
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
+ yyrealloc( (void *) b->yy_ch_buf,
b->yy_buf_size + 2 YY_CALL_LAST_ARG );
}
else
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
+ b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
YY_G(yy_current_buffer) = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
+ yyfree( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
- yy_flex_free( (void *) b YY_CALL_LAST_ARG );
+ yyfree( (void *) b YY_CALL_LAST_ARG );
}
/* They forgot to leave room for the EOB's. */
return 0;
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
/* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2;
- buf = (char *) yy_flex_alloc( n YY_CALL_LAST_ARG );
+ buf = (char *) yyalloc( n YY_CALL_LAST_ARG );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
new_size = YY_G(yy_start_stack_depth) * sizeof( int );
if ( ! YY_G(yy_start_stack) )
- YY_G(yy_start_stack) = (int *) yy_flex_alloc( new_size YY_CALL_LAST_ARG );
+ YY_G(yy_start_stack) = (int *) yyalloc( new_size YY_CALL_LAST_ARG );
else
- YY_G(yy_start_stack) = (int *) yy_flex_realloc(
+ YY_G(yy_start_stack) = (int *) yyrealloc(
(void *) YY_G(yy_start_stack), new_size YY_CALL_LAST_ARG );
if ( ! YY_G(yy_start_stack) )
yyscan_t* ptr_yy_globals;
#endif
{
- *ptr_yy_globals = (yyscan_t) yy_flex_alloc ( sizeof( struct yy_globals_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yy_globals_t ), NULL );
yy_init_globals ( *ptr_yy_globals );
return 0;
}
#if defined(YY_STACK_USED) || defined(YY_REENTRANT)
/* Destroy the start condition stack. */
if (YY_G(yy_start_stack) ){
- yy_flex_free( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
+ yyfree( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
YY_G(yy_start_stack) = NULL;
}
#endif
#ifdef YY_REENTRANT
/* Destroy the main struct (reentrant only). */
- yy_flex_free ( yy_globals YY_CALL_LAST_ARG );
+ yyfree ( yy_globals YY_CALL_LAST_ARG );
#endif
return 0;
}
}
#endif
-/* You may override yy_flex_alloc by defining YY_NO_FLEX_ALLOC and linking to
+/* You may override yyalloc by defining YY_NO_FLEX_ALLOC and linking to
* your own version */
#ifndef YY_NO_FLEX_ALLOC
#ifdef YY_USE_PROTOS
-void *yy_flex_alloc( yy_size_t size YY_LAST_ARG )
+void *yyalloc( yy_size_t size YY_LAST_ARG )
#else
-void *yy_flex_alloc( size YY_LAST_ARG )
+void *yyalloc( size YY_LAST_ARG )
yy_size_t size;
YY_DECL_LAST_ARG
#endif
}
#endif
-/* You may override yy_flex_realloc by defining YY_NO_FLEX_REALLOC and linking
+/* You may override yyrealloc by defining YY_NO_FLEX_REALLOC and linking
* to your own version. */
#ifndef YY_NO_FLEX_REALLOC
#ifdef YY_USE_PROTOS
-void *yy_flex_realloc( void *ptr, yy_size_t size YY_LAST_ARG )
+void *yyrealloc( void *ptr, yy_size_t size YY_LAST_ARG )
#else
-void *yy_flex_realloc( ptr, size YY_LAST_ARG )
+void *yyrealloc( ptr, size YY_LAST_ARG )
void *ptr;
yy_size_t size;
YY_DECL_LAST_ARG
}
#endif
-/* You may override yy_flex_free by defining YY_NO_FLEX_FREE and linking to
+/* You may override yyfree by defining YY_NO_FLEX_FREE and linking to
* your own version.*/
#ifndef YY_NO_FLEX_FREE
#ifdef YY_USE_PROTOS
-void yy_flex_free( void *ptr YY_LAST_ARG )
+void yyfree( void *ptr YY_LAST_ARG )
#else
-void yy_flex_free( ptr YY_LAST_ARG )
+void yyfree( ptr YY_LAST_ARG )
void *ptr;
YY_DECL_LAST_ARG
#endif
{
- free( (char *) ptr ); /* see yy_flex_realloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#endif
yyrestart
yytext
yywrap
+ yyalloc
+ yyrealloc
+ yyfree
@end verbatim
@end example
@findex yyset_lineno
@findex yyget_debug
@findex yyset_debug
+@findex yyget_extra
+@findex yyset_extra
@example
@verbatim
@chapter Memory Management
@cindex memory management
-@cindex alloc, overriding
-@cindex malloc, overriding
-@cindex realloc, overriding
-@cindex free, overriding
+@cindex yyalloc, overriding
+@cindex yyrealloc, overriding
+@cindex yyfree, overriding
@cindex yytext, memory for
This chapter describes how flex handles dynamic memory, and how you can
@node Overriding The Default Memory Management
@section Overriding The Default Memory Management
-TODO -- Describe how to override yy_flex_(alloc,free,realloc),
+TODO -- Describe how to override yy(alloc,free,realloc),
YY_READ_BUF_SIZE, YY_BUF_SIZE, YY_START_STACK_INCR, and anything else that
crops up.
GEN_PREFIX( "get_text" );
GEN_PREFIX( "get_lineno" );
GEN_PREFIX( "set_lineno" );
+ GEN_PREFIX( "alloc" );
+ GEN_PREFIX( "realloc" );
+ GEN_PREFIX( "free" );
outn( "#ifdef YY_REENTRANT_BISON_PURE" );
GEN_PREFIX( "get_lval" );
fprintf(header_out,"#undef YY_MORE_ADJ\n");
fprintf(header_out,"#undef YY_NEED_STRLEN\n");
fprintf(header_out,"#undef YY_NEW_FILE\n");
+ fprintf(header_out,"#undef YY_NO_FLEX_ALLOC\n");
+ fprintf(header_out,"#undef YY_NO_FLEX_REALLOC\n");
+ fprintf(header_out,"#undef YY_NO_FLEX_FREE\n");
fprintf(header_out,"#undef YY_NO_GET_DEBUG\n");
fprintf(header_out,"#undef YY_NO_GET_EXTRA\n");
fprintf(header_out,"#undef YY_NO_GET_IN\n");
fprintf(header_out,"#undef yy_switch_to_buffer\n");
fprintf(header_out,"#undef yyconst\n");
fprintf(header_out,"#undef yyextra\n");
+ fprintf(header_out,"#undef yyget_debug\n");
+ fprintf(header_out,"#undef yyset_debug\n");
fprintf(header_out,"#undef yyget_extra\n");
fprintf(header_out,"#undef yyget_in\n");
fprintf(header_out,"#undef yyget_leng\n");
fprintf(header_out,"#undef yytext\n");
fprintf(header_out,"#undef yytext_ptr\n");
fprintf(header_out,"#undef yywrap\n");
+ fprintf(header_out,"#undef yyalloc\n");
+ fprintf(header_out,"#undef yyrealloc\n");
+ fprintf(header_out,"#undef yyfree\n");
/* undef any of the auto-generated symbols. */
for(i=0; i < defs_buf.nelts; i++)
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
- yy_flex_alloc ACTION_IFDEF("YY_NO_FLEX_ALLOC", ! option_sense);
- yy_flex_realloc ACTION_IFDEF("YY_NO_FLEX_REALLOC", ! option_sense);
- yy_flex_free ACTION_IFDEF("YY_NO_FLEX_FREE", ! option_sense);
+ yyalloc ACTION_IFDEF("YY_NO_FLEX_ALLOC", ! option_sense);
+ yyrealloc ACTION_IFDEF("YY_NO_FLEX_REALLOC", ! option_sense);
+ yyfree ACTION_IFDEF("YY_NO_FLEX_FREE", ! option_sense);
yyget_debug ACTION_IFDEF("YY_NO_GET_DEBUG", ! option_sense);
yyset_debug ACTION_IFDEF("YY_NO_SET_DEBUG", ! option_sense);
%option 8bit outfile="scanner.c" prefix="test"
%option nounput nomain noyywrap
%option warn stack nodefault
-%option noyy_flex_alloc noyy_flex_realloc noyy_flex_free
+%option noyyalloc noyyrealloc noyyfree
%x parens
fprintf(fp,"}\n");
}
-void * yy_flex_alloc(size_t n YY_LAST_ARG)
+void * yyalloc(size_t n YY_LAST_ARG)
{
void * p;
struct memsz * old;
return p;
}
-void * yy_flex_realloc(void* p, size_t n YY_LAST_ARG)
+void * yyrealloc(void* p, size_t n YY_LAST_ARG)
{
int i;
for (i=0; i < arrsz; i++)
exit(1);
}
-void yy_flex_free(void* p YY_LAST_ARG)
+void yyfree(void* p YY_LAST_ARG)
{
int i;
for (i=0; i < arrsz; i++)
%option 8bit outfile="scanner.c" prefix="test"
%option nounput nomain noyywrap
%option warn stack nodefault reentrant
-%option noyy_flex_alloc noyy_flex_realloc noyy_flex_free
+%option noyyalloc noyyrealloc noyyfree
%x parens
fprintf(fp,"}\n");
}
-void * yy_flex_alloc(size_t n YY_LAST_ARG)
+void * yyalloc(size_t n YY_LAST_ARG)
{
void * p;
struct memsz * old;
return p;
}
-void * yy_flex_realloc(void* p, size_t n YY_LAST_ARG)
+void * yyrealloc(void* p, size_t n YY_LAST_ARG)
{
int i;
for (i=0; i < arrsz; i++)
exit(1);
}
-void yy_flex_free(void* p YY_LAST_ARG)
+void yyfree(void* p YY_LAST_ARG)
{
int i;
for (i=0; i < arrsz; i++)