From: Willy Tarreau Date: Fri, 29 Aug 2014 13:19:33 +0000 (+0200) Subject: BUG/MINOR: pattern: remove useless allocation of unused trash in pat_parse_reg() X-Git-Tag: v1.6-dev1~327 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5def8ef7864339b3e1e01a6c621e0c831c9e3bac;p=thirdparty%2Fhaproxy.git BUG/MINOR: pattern: remove useless allocation of unused trash in pat_parse_reg() Just like previous patch, this is a remains of an early implementation. Also fix the outdated comments above. The fix may be backported to 1.5 though the bug cannot be triggerred, thus it's just a matter of keeping the code clean. --- diff --git a/src/pattern.c b/src/pattern.c index b02dfb8643..c63365d74b 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -178,19 +178,15 @@ static inline unsigned int make_4delim(unsigned char d1, unsigned char d2, unsig * * These functions are exported and may be used by any other component. * - * The following functions are used for parsing pattern matching - * input value. The contain the string to be parsed. - * must be a preallocated pattern. The pat_parse_* functions fill this - * structure with the parsed value. can be PAT_U_COMPILE or - * PAT_U_LOOKUP. If the value PAT_U_COMPILE is used memory is allocated - * for filling the pattern. If the value PAT_U_LOOKUP is set, the parser - * use "trash" or return pointers to the input strings. In both cases, - * the caller must use the value PAT_U_LOOKUP with caution. is - * filled with an error message built with memprintf() function. - * - * In succes case, the pat_parse_* function return 1. If the function - * fail, it returns 0 and is filled. + * The following functions are used for parsing pattern matching input value. + * The contain the string to be parsed. must be a preallocated + * pattern. The pat_parse_* functions fill this structure with the parsed value. + * is filled with an error message built with memprintf() function. It is + * allowed to use a trash as a temporary storage for the returned pattern, as + * the next call after these functions will be pat_idx_*. * + * In success case, the pat_parse_* function returns 1. If the function + * fails, it returns 0 and is filled. */ /* ignore the current line */ @@ -223,17 +219,7 @@ int pat_parse_bin(const char *text, struct pattern *pattern, int mflags, char ** /* Parse a regex. It is allocated. */ int pat_parse_reg(const char *text, struct pattern *pattern, int mflags, char **err) { - struct chunk *trash; - - trash = get_trash_chunk(); - if (trash->size < sizeof(*pattern->ptr.reg)) { - memprintf(err, "no space avalaible in the buffer. expect %d, provides %d", - (int)sizeof(*pattern->ptr.reg), trash->size); - return 0; - } - pattern->ptr.str = (char *)text; - return 1; }