TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: you
from: Jerry Coffin
date: 2003-09-11 21:05:50
subject: Re: Pointers

From: jcoffin{at}taeus.com
To: c_echo{at}yahoogroups.com

At 09:32 PM 9/11/2003 -0500, you wrote:

[ ... ]

>Arguably even better are...
>
>         assert(x = malloc(somesize));

I'd argue that this is a whole lot worse -- as soon as you do a
non-debugging build, the allocation disappears completely!

>...or...
>
>#define MALLOC(ptr,size) if(NULL==(ptr=malloc(size))) abort()
>
>         MALLOC(x, somesize);

Not as bad as the one above, but it's still only good if you consistently
want to abort when/if you run out of memory.  At least to me, abort seems
pretty drastic -- if I was going to use something like this, I'd generally
prefer to use exit(), so there's at least a chance for cleanup to
happen.  Of course, if you're out of memory, that _might_ fail (at least
partially) as well, but I'd rather take a chance on a clean exit than
ensure against the possibility.
         Later,
         Jerry.

--- SoupGate-Win32 v1.05
* Origin: jcoffin{at}taeus.com (2:292/516.666)
SEEN-BY: 633/267 270
@PATH: 292/516 854 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.