[Discuss] Casting the return value of malloc bad?

Daniel M. German dmgerman at uvic.ca
Sun Jul 16 14:45:21 PDT 2006


 George Farris twisted the bytes to say:

 George> On Sat, 2006-15-07 at 13:48 -0700, Adam Parkin wrote:
 >> Andrew Resch wrote:
 >> >> Paul Nienaber wrote:
 >> >>> Do it this way:
 >> >>>
 >> >>> foo = malloc(n * sizeof(*foo));
 >> >>

 George> If you are going to be doing stuff like this in C you should maybe have
 George> a look at glib.  The lower level library used with gtk.  It has some
 George> very nice routines for C programmers even if they aren't using gtk.

The discussion is academic, not practical ;) It is about training our students
to like (some) and hate (some) C/C++. The true C/C++ programmers will
like it and hate it at the same time :)



--
Daniel M. German                  "War is not violence and killing,
                                   pure and simple;
                                   war is _controlled_ violence
                                   for a purpose. The purpose of war
                                   is to support your government's
   R. Heinlein ->                  decisions by force."
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .

 


More information about the Discuss mailing list