From: Kumar Gala Date: Thu, 26 Jun 2008 10:17:10 -0500 Subject: [U-Boot-Users] [PATCH] fs: make the static array to dynamic allocation In-Reply-To: <1214491834-27033-1-git-send-email-daveliu@freescale.com> References: <1214491834-27033-1-git-send-email-daveliu@freescale.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Jun 26, 2008, at 9:50 AM, Dave Liu wrote: > Current fat.c have three 64KB static array, it makes > the BSS section larger. > Change the static to dynamic allocation. > > Signed-off-by: Dave Liu > --- > fs/fat/fat.c | 38 +++++++++++++++++++++++++++++++++++--- > 1 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/fs/fat/fat.c b/fs/fat/fat.c > index 49c78ed..8e054a6 100644 > --- a/fs/fat/fat.c > +++ b/fs/fat/fat.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -65,6 +66,37 @@ int disk_read (__u32 startblock, __u32 getsize, > __u8 * bufptr) > return -1; > } > > +__u8 *get_vfatname_block; > +__u8 *get_dentfromdir_block; > +__u8 *do_fat_read_block; > +static int fat_mem_done = 0; > +static int fat_memory_alloc(void) > +{ > + if (fat_mem_done) > + return 0; > + > + get_vfatname_block = (__u8 *)malloc(MAX_CLUSTSIZE); do you really need the cast? > > + if (!get_vfatname_block) { > + printf("alloc get_vfatname_block failed\n\r"); > + return -1; > + } > + > + get_dentfromdir_block = (__u8 *)malloc(MAX_CLUSTSIZE); ditto. > > + if (!get_dentfromdir_block) { > + printf("alloc get_dentfromdir_block failed\n\r"); > + return -1; > + } > + > + do_fat_read_block = (__u8 *)malloc(MAX_CLUSTSIZE); ditto > > + if (!do_fat_read_block) { > + printf("alloc do_fat_read_block failed\n\r"); > + return -1; > + } > + > + fat_mem_done = 1; > + > + return 0; > +} - k