Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Compilation problems??
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
![]() |
![]() |