Re: [PATCH 01/14] Fix non-constant array creation

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

 



On Fri, Aug 21, 2009 at 3:30 PM, Marius Storm-Olsen<mstormo@xxxxxxxxx> wrote:
> @@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img,
>                size_t imgoff = 0;
>                size_t preoff = 0;
>                size_t postlen = postimage->len;
> -               size_t imglen[preimage->nr];
> +               size_t *imglen = xmalloc(sizeof(size_t) * preimage->nr);

How about using alloca instead? It allocates from the stack (just like
the C99-style variable-length array you're replacing), and you don't
need to free the memory afterwards.

... or is alloca frowned upon? I see it's already used both in
compat/regex/regex.c and in compat/nedmalloc/malloc.c, but not
apparently not in the git core.

-- 
Erik "kusma" Faye-Lund
kusmabite@xxxxxxxxx
(+47) 986 59 656
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]