Re:Once upon a time, memory allocators made sense
by masklinn on Tuesday January 19, 2016 @05:52AM
(#10929871)
That requirement was present in C89 and removed in C99, which also added that a 0-sized allocation doesn't have to return a null pointer (whether done by malloc, calloc or realloc)
[ Parent
| on HN ]
Re:Once upon a time, memory allocators made sense
by kazinator on Tuesday January 19, 2016 @11:52AM
(#10931922)
Dang, is that right? See, I checked C99 when I posted the comment. I don't know where my old copy of C90 is, but I was mildly surprised. I had that WTF feeling "I could have sworn it was supposed to work that way!
In any case, if I'm compiling with -ansi or -std=c90 on a GCC-based platform that is hosted, the library had better behave in the C90 conforming manner. Only if if -std=c99 is used should it take the liberty with realloc(ptr, 0) being like malloc(0).