From: Reinhard Meyer Date: Thu, 14 Oct 2010 10:48:19 +0200 Subject: [U-Boot] RFC: introduce malloc_cleared() ? In-Reply-To: <20101014081302.226391365CF@gemini.denx.de> References: <4CB6A110.6080101@emk-elektronik.de> <20101014081302.226391365CF@gemini.denx.de> Message-ID: <4CB6C3D3.7050403@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Wolfgang Denk schrieb: > Dear Reinhard Meyer, > > In message <4CB6A110.6080101@emk-elektronik.de> you wrote: >> instead of adding or having the sequence of >> >> malloc(), memset() >> >> in all places where a definitely sane initialized structure >> is required it would make more sense to introduce a single >> function doing both. (The standard "calloc()" does not suit well >> here.) Overall that should even slightly decrease code size. > > And why exactly does calloc() not fit? It has two parameters... Produces more code to always supply an extra "1"... I am game with using calloc(). That's all. But for malloc() in such driver init situations, another code saving function with error message would be more effective. I don't see any possible way of continuing u-boot when malloc() for a relatively small structure already fails, and a (apparently) needed driver cannot be initialized. I am not talking about malloc()'s for buffers or similar where continuing of u-boot might be possible. Reinhard