From: Wolfgang Denk Date: Mon, 07 Oct 2013 07:34:24 +0200 Subject: [U-Boot] [PATCH] env_mmc: fix buffer allocation for armv7 In-Reply-To: <20131006204214.GO15917@bill-the-cat> References: <1380894483-6754-1-git-send-email-list-09_u-boot@tqsc.de> <20131004170203.GL15917@bill-the-cat> <20131005195728.AE316380A3C@gemini.denx.de> <20131006204214.GO15917@bill-the-cat> Message-ID: <20131007053424.B4FAD380435@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Tom, In message <20131006204214.GO15917@bill-the-cat> you wrote: > > > Why do you hesitate to use the stack? > > Mainly to allow us to work in restricted stack areas like SPL where we > simply may not have that much space available. But malloc() is drawing from the very same resource as the stack, even more so: with a buffer on the stack, the memory isfreed completeky upon return from the fucntion, with no reminders left. With malloc() you need to statically allocate the malloc pool size for the whole runtime, and allocating the buffers may fragment tha area, so even after freeing the buffers there is less space left for other purposes. Especially in memory-tight situations you want to avoid malloc(). 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 It's all Klatchian to me. - Terry Pratchett & Stephen Briggs, _The Discworld Companion_