On Fri, Apr 10, 1998 at 06:00:50PM -0500, Manoj Srivastava wrote:
> That is why I prefer to do:
> ------------------------------------------------------------
> free(ptr);
> ptr = 0;
> ----------------------------------------------------------------------
> (similarily for fclose).
Ditto, however in this case:
] $ cat test.c
] #include <stdio.h>
] int main(void) {
] FILE* f;
] f = NULL;
] fclose(f);
] return 0;
] }
] $ gcc -Wall -W -ansi -pedantic -o test test.c
] $ ./test
] Segmentation fault
] $ _
I couldn't find anything that says that's not allowable (cf free(NULL);
which is defined as harmless), but at the very least the manpages need
to be changed to reflect the actual behaviour here.
Cheers,
aj
--
Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. PGP encrypted mail preferred.
``It's not a vision, or a fear. It's just a thought.''
Attachment:
pgpYaavSUPGIZ.pgp
Description: PGP signature