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.
(cherry picked from commit 5def8ef7864339b3e1e01a6c621e0c831c9e3bac)
diff --git a/src/pattern.c b/src/pattern.c
index b02dfb8..c63365d 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -178,19 +178,15 @@
*
* These functions are exported and may be used by any other component.
*
- * The following functions are used for parsing pattern matching
- * input value. The <text> contain the string to be parsed. <pattern>
- * must be a preallocated pattern. The pat_parse_* functions fill this
- * structure with the parsed value. <usage> 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. <err> is
- * filled with an error message built with memprintf() function.
+ * The following functions are used for parsing pattern matching input value.
+ * The <text> contain the string to be parsed. <pattern> must be a preallocated
+ * pattern. The pat_parse_* functions fill this structure with the parsed value.
+ * <err> 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 succes case, the pat_parse_* function return 1. If the function
- * fail, it returns 0 and <err> is filled.
- *
+ * In success case, the pat_parse_* function returns 1. If the function
+ * fails, it returns 0 and <err> is filled.
*/
/* ignore the current line */
@@ -223,17 +219,7 @@
/* 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;
}