bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: pb with regex


From: Stepan Kasal
Subject: Re: pb with regex
Date: Tue, 18 May 2004 17:09:19 +0200
User-agent: Mutt/1.4.1i

Hello,
  in the original email, you said that you are not sure you use the
library correctly.  Perhaps the problem lies there.

You have to call regcomp() only once, to create the "compiled" version
of the regex.  Then you call regexec() several times to find matches
in various texts.  When you are done, you call regfree() to free the various
structures.

When the text of the regex changes, you have to call regfree() before
calling regcomp() again.  

The manual says:
   You should always free the space in a `regex_t' structure with
   `regfree' before using the structure to compile another regular
   expression.

An example with staticly allocated regex_t:
{
        regex_t myreg;

        regcomp(&myreg, text1, flags);
        regexec(&myreg, long_text, ...);
        regfree(&myreg);
        regcomp(&myreg, text2, flags);
        ...
}

Do you really use it this way?

On Tue, May 18, 2004 at 04:17:15PM +0200, PAROUX Vincent FTRD/DAC/LAN wrote:
> I followed all the function and I found that the system blocks on the macro
> re_malloc (file regex_internal.h)
> "#define re_malloc(t,n) ((t*)malloc((n)*sizeof(t)))" 
> 
> I replace the code of the macro by its code but it's the same.

If it really hangs inside malloc(), it could be a problem in glibc().
That would mean you have to try to upgrade/downgrade it.
But that might get scary...

Stepan Kasal




reply via email to

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