diff --git a/ChangeLog b/ChangeLog index acf26a955..7b5a8125b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2013-11-16 Vladimir Serbinenko + + Decrease stack usage in lexer. + + We have only 92K of stack and using over 4K per frame is wasteful + + * grub-core/script/yylex.l (yyalloc), (yyfree), (yyrealloc): Declare + as macros so that compiler would remove useless structure on stack. + Better solution would be to fix flex not to put this structure on + the stack but flex is external program. + 2013-11-16 Vladimir Serbinenko Decrease stack usage in signature verification. diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l index 6c61f855f..9c2cfe115 100644 --- a/grub-core/script/yylex.l +++ b/grub-core/script/yylex.l @@ -31,9 +31,9 @@ #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wsign-compare" -#define yyfree grub_lexer_yyfree -#define yyalloc grub_lexer_yyalloc -#define yyrealloc grub_lexer_yyrealloc +#define yyalloc(size, scanner) (grub_malloc((size))) +#define yyfree(ptr, scanner) (grub_free((ptr))) +#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size))) /* * As we don't have access to yyscanner, we cannot do much except to @@ -68,9 +68,6 @@ static int grub_lexer_unput (const char *input, yyscan_t yyscanner); static int grub_lexer_resplit (const char *input, yyscan_t yyscanner); -static void grub_lexer_yyfree (void *, yyscan_t yyscanner); -static void* grub_lexer_yyalloc (yy_size_t, yyscan_t yyscanner); -static void* grub_lexer_yyrealloc (void*, yy_size_t, yyscan_t yyscanner); static void copy_string (struct grub_parser_param *, const char *, unsigned hint); @@ -339,25 +336,6 @@ yywrap (yyscan_t yyscanner) return grub_script_lexer_yywrap (yyget_extra (yyscanner), 0); } -static void -grub_lexer_yyfree (void *ptr, yyscan_t yyscanner __attribute__ ((unused))) -{ - grub_free(ptr); -} - -static void* -grub_lexer_yyalloc (yy_size_t size, yyscan_t yyscanner __attribute__ ((unused))) -{ - return grub_malloc (size); -} - -static void* -grub_lexer_yyrealloc (void *ptr, yy_size_t size, - yyscan_t yyscanner __attribute__ ((unused))) -{ - return grub_realloc (ptr, size); -} - static void copy_string (struct grub_parser_param *parser, const char *str, unsigned hint) { grub_size_t size;