News for hackers. Stuff that matters.
Re:Once upon a time, memory allocators made sense by kazinator on Monday January 18, 2016 @01:10PM (#10925831)
realloc(ptr, 0) special case which (on some C libraries only) means the same thing as free(ptr) and not to realloc the object to zero size.

That's what the author's resize function expected, which is why his patch is to use free.

Re:Once upon a time, memory allocators made sense by fanf2 on Monday January 18, 2016 @07:21PM (#10928048)
C libraries do not conform to the standard if they do not free in this case.
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)
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).

Re:Once upon a time, memory allocators made sense by jheriko on Thursday January 21, 2016 @06:22AM (#10944551)
C libraries do not conform to the standard.