[Discuss] Casting the return value of malloc bad?

Adam Parkin pzelnip at telus.net
Sun Jul 16 20:51:10 PDT 2006


Daniel M. German wrote:
> I guess everybody has different "techniques". This is the one that I
> currently used, developed during my years as an IBMer:
> 
> int returnValue = -1;
> MyType *p = NULL;
> 
> do {
>     /* allocate memory and use a debug library to detect leaks */
>     p = malloc(sizeof(*p));
>     if (p == NULL) 
>        goto error;

AHHHHHH A GOTO!!!! =8-p

Sorry, had to be the first to say it. =;->
-- 
--
Adam Parkin
E-mail: pzelnip at telus.net
----------------------
You ask people why they have deer heads on the wall. They always say, 
Because it's such a beautiful animal. ... I think my mother's 
attractive, but I have photographs of her.

	-- Ellen DeGeneres


More information about the Discuss mailing list