> -----Original Message----- > From: openocd-development-boun...@lists.berlios.de [mailto:openocd- > development-boun...@lists.berlios.de] On Behalf Of Zach Welch > Sent: donderdag 17 december 2009 23:21 > To: Carsten Breuer > Cc: Openocd-development@lists.berlios.de > Subject: Re: [Openocd-development] malloc: Vote what to do > > On Thu, 2009-12-17 at 21:44 +0100, Carsten Breuer wrote: > > Hi all, > > > > > > after finding out, that malloc come back with NULL > > even on linux (where people says here, it don't), > > im starting to loose interest in the hole thing. > > > > So what should we do? > > > > I think now, that all this arguments not to check > > malloc result is academical and some arguments are not > > even true. > > I believe the actual argument against NULL checks was in the context of > NULL pointers passed into API functions. > > All returns from malloc should be checked for NULL. I will come to the > house of anyone who says otherwise with a 2"x4" clue club and knock them > over the head with it. If that fails, I will go for their kneecaps.
AFAIK the argument is also that on Linux malloc will never return NULL. When memory gets low, a (sort off) randomly selected process is killed instead. Still, OpenOCD may run on other platforms like Windows where malloc probably returns NULL when memory is about to be depleted. So yes, checking for NULL is mandatory. IMHO there shouldn't be any voting on that matter. Not checking return values (especially pointers) is just sloppy Microsoft-ish programming and should be fixed. Nico Coesel _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development