bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Patch] faster fnmatch


From: Ralf Wildenhues
Subject: Re: [Patch] faster fnmatch
Date: Fri, 1 May 2009 21:50:23 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hello Ondrej,

* Ondrej Bilka wrote on Fri, May 01, 2009 at 09:36:39PM CEST:
> +#define  NULTEST(...) if (__builtin_expect(!(__VA_ARGS__),0)) return NULL;
> +#define  NULTEST2(...) if (__builtin_expect(!(__VA_ARGS__),0)) return -1;
[...]
> +static fnmatch_state *
> +initfnmatchstate ()
> +{
> +  fnmatch_state *st;
> +  NULTEST (st = (fnmatch_state *) malloc (sizeof (fnmatch_state)));
> +  NULTEST (st->states = malloc (sizeof (struct states)));

That NULTEST thing is cute but makes me cringe.  If the second malloc
runs out of memory, then you return, but leak memory from the first
malloc.  So in a tight memory situation, your code starts contributing
to the problem.

Also, __VA_ARGS__ requires a C99 compiler.

Cheers,
Ralf




reply via email to

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