Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Compilation problems??

Re: Compilation problems??

From: Chris Engebretson <engebrec_at_remove-me.brookings.net>
Date: 1997/08/25
Message-ID: <34011851.21FD@remove-me.brookings.net>#1/1

Peter Shaggy Haywood wrote:

> > char *ls_getvalue;
> > int li_valid;
> >
> > ls_getvalue = (char*) malloc(80);
>
> Check the return from malloc() to make sure nothing went wrong:

And ditch the (char *) cast.

> > if (li_valid == 0)
> > {
> > printf("ls_getvalue is: %s\n", ls_getvalue);
> > free (ls_getvalue);
> > ls_getvalue = 0;
>
> Keep it portable. Use NULL instead of 0 here.

While NULL may be slightly more descriptive, there is nothing wrong with using 0. An unadorned 0 in a pointer context is required by the language to represent a null pointer of that particular type.  

Regards,

-- 
Chris Engebretson - (return and reply-to addresses are doctored)
I dislike spam.  On the other hand, lucky_at_powernet.net loves it.
Received on Mon Aug 25 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US