[U-Boot] C99 and dynamic arrays

Wolfgang Denk wd at denx.de
Wed Mar 13 17:06:46 CET 2013


Dear Simon Glass,

In message <CAPnjgZ2bSf8-9gw6MweexMUEXDTYNspxth0GA0XN3RpkLO4R8w at mail.gmail.com> you wrote:
>
> >> Given that we seem to allow C99 features in U-Boot I wonder if it
> >> would be OK to use dynamic arrays in SPL?

Strange.  I can see the follow-ups, but I cannot see the original
posting?

> In the function pow_mod(), I would like to replace:
> 
> val = malloc(key->len * sizeof(uint32_t));
> 
> with:
> 
> uint32_t val[key->len];
> 
> malloc() adds at least 1KB, perhaps 2KB.

I think it is perfectly OK to do that.  Actually I think we already do
this in a number of places.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The trouble with doing something right the first time is that nobody
appreciates how difficult it was."                        - Walt West


More information about the U-Boot mailing list