Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!gwyn From: gwyn@brl-tgr.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: Immoral bugs Message-ID: <2140@brl-tgr.ARPA> Date: Sat, 1-Feb-86 19:00:53 EST Article-I.D.: brl-tgr.2140 Posted: Sat Feb 1 19:00:53 1986 Date-Received: Mon, 3-Feb-86 05:28:29 EST References: <3090012@csd2.UUCP> Organization: Ballistic Research Lab Lines: 25 > I thought I'd point out a couple of minor bugs in the fast "immoral" > routines that were just posted... Great! I hope people get the point about "clever" code.. #include #include void * calloc( unsigned nelem, unsigned elsize ) { register void *ptr; nelem *= elsize; if ( (ptr = malloc( nelem )) != 0 ) (void) memset( (char *)ptr, 0, nelem ); return ptr; } Note that calloc() is pretty much useless. How often do you really want a malloc()ed block of storage filled with NUL characters rather than some other sort of 0, e.g. NULL pointers, floating-point 0.0s, etc.?