Hello Wilfred,
Friday March 12 2021, Wilfred van Velzen wrote to Michael Dukelsky:
ac>>>> #define nfree(a) {if(a != NULL) {free(a); a = NULL;}}
WV>>> And the test for NULL isn't necessary, because free() is by
WV>>> definition doing nothing if the pointer passed to it is NULL.
MD>> Yes, I know it. It was written long ago and not by me and I do
MD>> not change it because I do not know whether free() always worked
MD>> as it works now or it did not test the pointer for NULL in some
MD>> ancient systems.
WV> The Second Edition (1988) of The C Programming Language by Kernighan &
WV> Ritchie (describes C as defined by the ANSI standard), already
WV> describes it as follows:
WV> void free(void *p)
WV> free deallocates the space pointed to by p; it does nothing if p is
WV> NULL. p must be a pointer to space previously allocated by calloc,
WV> malloc, or realloc.
WV> So I think you are save to assume it "always" worked that way! ;)
OK, thanks.
Michael
... node (at) f1042 (dot) ru
--- GoldED+/LNX 1.1.5-b20180707
* Origin: Moscow, Russia (2:5020/1042)
|