From: "Peter Ajamian" <peter@PAJAMIAN.DHS.ORG>
> > > if (obj->description &&
> > > obj->description != obj_proto[GET_OBJ_RNUM(obj)].description)
> > > free(obj->description);
> > > obj->description = str_dup("A dagger lies here.");
> >
> > That code should work fine, although the first condition of your if is
not
> > necessary.
>
> Not necessary, but it's a good safegaurd nonetheless.
Untrue. Under ANSI C and every compiler I used it is perfectly valid to
call free(0). It causes no error, no complaint, no action-- it does
nothing. Incidentally, the same is true of "delete" in C++. Basically, the
rule is you can pass to free any value that was returned by malloc. Since
malloc can return 0, it is valid to pass 0 to free.
Mike
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/05/01 PST