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