diff options
Diffstat (limited to 'libglusterfs/src/graph.l')
-rw-r--r-- | libglusterfs/src/graph.l | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l index 4447191ac73..b9d4b2b6828 100644 --- a/libglusterfs/src/graph.l +++ b/libglusterfs/src/graph.l @@ -17,32 +17,24 @@ #include "glusterfs/xlator.h" #include "y.tab.h" #include <string.h> -#define START_STRSIZE 32 static char *text; -static int text_asize; static int text_size; void append_string(const char *str, int size) { - int new_size = text_size + size + 1; - if (new_size > text_asize) { - new_size += START_STRSIZE - 1; - new_size &= -START_STRSIZE; - if (!text) { - text = GF_CALLOC (1, new_size, - gf_common_mt_char); - } else { - text = GF_REALLOC (text, new_size); - } - if (!text) { - return; - } - text_asize = new_size; - } - memcpy(text + text_size, str, size); - text_size += size; - text[text_size] = 0; + int new_size = text_size + size + 1; + if (!text) { + text = GF_CALLOC (1, new_size, gf_common_mt_char); + } else { + text = GF_REALLOC (text, new_size); + } + if (!text) { + return; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; } %} @@ -65,12 +57,14 @@ TYPE [t][y][p][e] \\. { append_string (yytext + 1, yyleng - 1); } \" { if (0) { - yyunput (0, NULL); + yyunput (0, NULL); } BEGIN (INITIAL); graphyylval = text; + text = NULL; + text_size = 0; return STRING_TOK; - } + } } [^ \t\r\n\"\\]+ { graphyylval = gf_strdup (yytext) ; return ID; } [ \t\r\n]+ ; |