Path: utzoo!attcan!uunet!indetech!schmidt From: schmidt@indetech.com (Doug Schmidt) Newsgroups: comp.lang.c Subject: validity of free() on later pointer operations Message-ID: <1990Jul3.185032.8434@indetech.com> Date: 3 Jul 90 18:50:32 GMT Reply-To: schmidt@indetech.UUCP (Doug Schmidt) Organization: Independence Technologies, Inc. Fremont, CA Lines: 34 Hi, Several months ago there was a big discussion on comp.lang.c about the legality/portability of the following sort of code: ---------------------------------------- void foo (n) int n; { char *malloc (); char *s = malloc (n); /* ... */ free (s); s = 0; /* Is this assignment always legal? */ /* ... */ } ---------------------------------------- I seem to recall there was a problem with the assignment to char *s *after* the free. Can someone please refresh my memory as to what the problem was, and why it is a problem? Would replacing s = 0 by s = malloc (n) have the same problem? thanks, Doug -- ____*_ Douglas C. Schmidt schmidt@indetech.com \ / / Independence Technologies {sun,sharkey,pacbell}!indetech!schmidt \/ / 42705 Lawrence Place FAX: 415 438-2034 \/ Fremont, CA 94538 Voice: 415 438-2023