delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/17/23:35:10

From: "John M. Aldrich" <fighteer AT NO DOT SPAM DOT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Try this one on for size
Date: Thu, 17 Apr 1997 07:38:55 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 28
Message-ID: <3355D38F.ED2@NO.SPAM.cs.com>
References: <199704162029 DOT QAA02720 AT hcst DOT net> <33546C31 DOT 6872 AT NO DOT SPAM DOT cs DOT com> <335631CF DOT 1F90 AT cornell DOT edu>
NNTP-Posting-Host: ppp208.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

A. Sinan Unur wrote:
> 
> >   struct big_bad_struct *x;
> >   x = malloc( sizeof(x) );
> >
> > I leave it up to you to determine why this is wrong.  ;)
> 
> x = (struct big_bad_struct *) malloc (sizeof(big_bad_struct));
> 
> sorry, couldn't resist the temptation.

While you're right in principle, one of the tenets of abstract design is
that you should have as little contact with the internals of a data
structure as possible.  Using the variable name itself makes for much
more understandable code, IMHO.  Then again, maybe not.  I'm not going
to get into an argument about it.  ;)

-- 
John M. Aldrich <fighteer AT cs DOT com>                      

* Anything that happens, happens.
* Anything that, in happening, causes something else to happen,
  causes something else to happen.
* Anything that, in happening, causes itself to happen again, happens
  again.
* It doesn't necessarily do it in chronological order, though.
 
                                       --- Douglas Adams

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019