From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans de Goede Date: Sun, 12 Oct 2014 10:49:44 +0200 Subject: [U-Boot] New discussion proposal for u-boot summit: "switch malloc to succeed or die model, as glib does" In-Reply-To: <543A3EF4.9050304@redhat.com> References: <543A3EF4.9050304@redhat.com> Message-ID: <543A40A8.1030204@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, On 10/12/2014 10:42 AM, Hans de Goede wrote: > Hi All, > > Sorry for the poor timing in bringing this up, but this just > came up when discussing the review of some sunxi patches. > > Ian asked me to add error handling for mmc_create failing, > which, if used properly, only ever fails if calloc fails. > > This made me thinking that we should switch u-boot to the > glib memory alloc failure handling model, which is put a > die() / abort() inside the low level malloc routines when > they fail. I remembered that I've already seen something like this in u-boot, so after some grepping around I've found that at least common/cli_hush.c already does this. It introduces a (private) xmalloc and xrealloc which have the malloc_or_die behavior. Regards, Hans