fdtoverlay: Switch from using alloca to malloc
PATCH 1/1 fdtoverlay: Switch from using alloca to malloc
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 <[email protected]>
--- fdtoverlay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fdtoverlay.c +2 -2
@@ -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);
Signature · 1 line
2.15.1
A message that is not in the archive (sent off-list or not yet received): 20180103030538.46326-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org
David Gibson
AppliedQuoted 7 lines · On Tue, Jan 02, 2018 at 09:05:38PM -0600…
alloca entails a complicated header situation when using other platforms, where some split it out in
alloca.hwhile others include it as a standard part ofstdlib.h.The cons don't seem to outweigh the pros, so switch it to malloc.
Signed-off-by Kyle Evans <[email protected]>
Applied, thanks.
Quoted 33 lines
--- fdtoverlay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fdtoverlay.c +2
-2@@ -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);
Signature · 4 lines
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