From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22191 invoked by alias); 5 Jan 2004 21:49:17 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 22174 invoked from network); 5 Jan 2004 21:49:15 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 5 Jan 2004 21:49:15 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i05JgMgY024319; Mon, 5 Jan 2004 20:42:22 +0100 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i05JgMdU024317; Mon, 5 Jan 2004 20:42:22 +0100 Date: Mon, 05 Jan 2004 21:49:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Sync regfree with old regex Message-ID: <20040105194221.GS2020@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-01/txt/msg00007.txt.bz2 Hi! Old regex was freeing preg->translate in regfree as well as clearing the fields so that the re_pattern_buffer can be immediately reused by another re_compile_pattern. This patch should make zero difference for the POSIX interface (regcomp initializes all those 4 fields and never sets preg->translate) and should bring regfree behaviour after re_compile_pattern to how it used to work (given the lack of good enough specification for the re_* API I think the old regex should be the ultimate specification). 2004-01-05 Jakub Jelinek * posix/regcomp.c (regcomp): Fix comment typo. (regfree): Free preg->translate, clear buffer, allocated, fastmap and translate fields. --- libc/posix/regcomp.c.jj 2004-01-05 12:53:47.000000000 +0100 +++ libc/posix/regcomp.c 2004-01-05 21:37:17.000000000 +0100 @@ -503,7 +503,7 @@ regcomp (preg, pattern, cflags) /* We have already checked preg->fastmap != NULL. */ if (BE (ret == REG_NOERROR, 1)) /* Compute the fastmap now, since regexec cannot modify the pattern - buffer. This function nevers fails in this implementation. */ + buffer. This function never fails in this implementation. */ (void) re_compile_fastmap (preg); else { @@ -632,8 +632,14 @@ regfree (preg) re_dfa_t *dfa = (re_dfa_t *) preg->buffer; if (BE (dfa != NULL, 1)) free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; re_free (preg->fastmap); + preg->fastmap = NULL; + + re_free (preg->translate); + preg->translate = NULL; } #ifdef _LIBC weak_alias (__regfree, regfree) Jakub