Re: [PATCH] fdtoverlay: Switch from using alloca to malloc

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



On Tue, Jan 02, 2018 at 09:05:38PM -0600, kevans@xxxxxxxxxxx wrote:
> alloca entails a complicated header situation when using other platforms, where
> some split it out in alloca.h while others include it as a standard part of
> stdlib.h.
> 
> The cons don't seem to outweigh the pros, so switch it to malloc.
> 
> Signed-off-by: Kyle Evans <kevans@xxxxxxxxxxx>

Applied, thanks.

> ---
>  fdtoverlay.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fdtoverlay.c b/fdtoverlay.c
> index 7f124fc..62a942d 100644
> --- a/fdtoverlay.c
> +++ b/fdtoverlay.c
> @@ -26,7 +26,6 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> -#include <alloca.h>
>  #include <inttypes.h>
>  
>  #include <libfdt.h>
> @@ -79,7 +78,7 @@ static int do_fdtoverlay(const char *input_filename,
>  	ret = 0;
>  
>  	/* allocate blob pointer array */
> -	ovblob = alloca(sizeof(*ovblob) * argc);
> +	ovblob = malloc(sizeof(*ovblob) * argc);
>  	memset(ovblob, 0, sizeof(*ovblob) * argc);
>  
>  	/* read and keep track of the overlay blobs */
> @@ -121,6 +120,7 @@ out_err:
>  			if (ovblob[i])
>  				free(ovblob[i]);
>  		}
> +		free(ovblob);
>  	}
>  	free(blob);
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux