Re: [PATCH v2] parser: don't keep alloca()ing in a loop for substitutions

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

 



наб <nabijaczleweli@xxxxxxxxxxxxxxxxxx> wrote:
>
> Naturally, I hadn't considered that.
> 
> This version I've run through valgrind in a good few configurations and
> am happy to conclude there are no leaks (and the memory usage bump is
> imperceptible unless you were almost-crashing anyway).

Nice work!

> @@ -1446,10 +1443,8 @@ done:
>        if (oldstyle)
>                tokpushback = 0;
>        out = growstackto(savelen + 1);
> -       if (str) {
> -               memcpy(out, str, savelen);
> -               STADJUST(savelen, out);
> -       }
> +       memcpy(out, str, savelen);
> +       STADJUST(savelen, out);

Minor nit but these three lines can be combined into:

	out = stnputs(stackblock(), str, savelen);

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux