faq & casting malloc()
From: tweak (xbwaichunasx_at_cox.net)
Date: 06/23/04
- Next message: CBFalconer: "Re: (OT) English language question"
- Previous message: Allin Cottrell: "gcc prototype oddity"
- In reply to: Emmanuel Delahaye: "Re: simple malloc() problem"
- Next in thread: Keith Thompson: "Re: faq & casting malloc()"
- Reply: Keith Thompson: "Re: faq & casting malloc()"
- Reply: pete: "Re: faq & casting malloc()"
- Reply: Darrell Grainger: "Re: faq & casting malloc()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Jun 2004 18:22:44 -0700
Emmanuel Delahaye wrote:
> Your problem is covered by the FAQ:
>
> http://www.eskimo.com/~scs/C-faq/q4.8.html
I went to the faq and it looks like:
void f(ip)
int *fp;
{
static int dummy = 5;
ip = &dummy;
}
shouldn't the above read:
int *fp;
void f(ip) {
static int dummy = 5;
ip = &dummy;
}
If so, could you correct it?
Brian
P.S. The FAQ really does answer the question even
though the poster thought their problem
was malloc(), which had the wrong size_t --
cutting off '\0'.
Note: The only item I can find regarding casting
of malloc() is K&R2 pg. 142:
"In C, the proper method is to declare that
malloc return a pointer to void, then
explicitly coerce the pointer into the
desired type with cast."
Now, I couldn't find anything specific in
ISO C99, so I guess it's up to the programmer
to decide.
- Next message: CBFalconer: "Re: (OT) English language question"
- Previous message: Allin Cottrell: "gcc prototype oddity"
- In reply to: Emmanuel Delahaye: "Re: simple malloc() problem"
- Next in thread: Keith Thompson: "Re: faq & casting malloc()"
- Reply: Keith Thompson: "Re: faq & casting malloc()"
- Reply: pete: "Re: faq & casting malloc()"
- Reply: Darrell Grainger: "Re: faq & casting malloc()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|