Re: Help with understanding this please



On Aug 30, 7:11 am, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
mdh said:


struct t_node_n{
char *word;
int match;
struct t_node_n *left;
struct t_node_n *right;
};

struct t_node_n *temp = (struct t_node_n *) malloc(sizeof(struct
t_node_n));

Better: struct t_node_n *temp = malloc(sizeof *temp);

Cleaner, tighter, less maintenance hassle.

Richard...before I rest so that sleep can be calm!!, may I ask why you
have not cast the return from malloc to type "struct t_node n *). K&R
devote quite a discussion to this on page 142.

Thanks as always.

.



Relevant Pages

  • Re: Help with understanding this please
    ... Cleaner, tighter, less maintenance hassle. ... Richard...before I rest so that sleep can be calm!!, ...
    (comp.lang.c)
  • Re: RA - questions
    ... I just need a decent nights ... sleep to help me get thru the day. ... OK, I'm not a doctor. ... some prednisone for a short time to calm it down. ...
    (alt.support.arthritis)
  • Re: dirty boy
    ... calm him to sleep. ... drift off after a few minutes. ... I can't imagine a 9 week old dog humping like that, ...
    (rec.pets.dogs.behavior)
  • RIP Brian Renshaw Artist
    ... Brian Renshaw died in his sleep last Thursday night. ... A gentle modest man who now gone from among us, his calm, atmospheric paintings of old town Hastings will remain as a tribute to his skill and depth of insight. ...
    (soc.culture.scottish)
  • Good news for today!
    ... and I've decided to devote it all to YOU guys! ... Yes, that's right, calm your tiny boners, I will be here ALL DAY LONG, ... punkass bitches you all are when you see how a REAL man worksout. ...
    (misc.fitness.weights)