help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug(s) in 2.5.19 skel.c


From: Bruce Lilly
Subject: Re: bug(s) in 2.5.19 skel.c
Date: Sun, 15 Sep 2002 14:42:59 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Bruce Lilly wrote:
A simpler and more effective alternative (since)
only a few elements of the struct need to be
initialized to something other thsn zero) would
be either:
1. use calloc rather than malloc
or
2. use memset() after malloc.
Then yy_init_globals only has to take care of
the elements that need to be initialized to non-xero
values.

The attached patch implements the second option.



*** skel.c.orig Sat Sep 14 22:32:14 2002
--- skel.c      Sun Sep 15 14:05:24 2002
***************
*** 2020,2040 ****
    "#ifdef YY_USE_LINENO",
    "    yylineno =  1;",
    "#endif",
-   "    YY_G(yy_current_buffer) = 0;",
-   "    YY_G(yy_c_buf_p) = (char *) 0;",
    "    YY_G(yy_init) = 1;",
-   "    YY_G(yy_start) = 0;",
-   "    YY_G(yy_start_stack_ptr) = 0;",
-   "    YY_G(yy_start_stack_depth) = 0;",
-   "    YY_G(yy_start_stack) = (int *) 0;",
    "",
    "/* Defined in main.c */",
    "#ifdef YY_STDINIT",
    "    yyin = stdin;",
    "    yyout = stdout;",
-   "#else",
-   "    yyin = (FILE *) 0;",
-   "    yyout = (FILE *) 0;",
    "#endif",
    "",
    "    /* For future reference: Set errno on error, since we are called by",
--- 2020,2031 ----
***************
*** 2067,2072 ****
--- 2058,2064 ----
    "        return 1;",
    "    }",
    "",
+   "    memset(*ptr_yy_globals, 0, sizeof( struct yyguts_t ));",
    "    return yy_init_globals ( *ptr_yy_globals );",
    "    }",
    "",

reply via email to

[Prev in Thread] Current Thread [Next in Thread]