> ? what does Windows do?

There's quite a bit of documentation:

<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/realloc?view=msvc-170>

My favorite part is actually this:

| realloc hasn't been updated to implement C17 behavior because the new
| behavior isn't compatible with the Windows operating system.

The realloc specification update was supposed to be an editorial change
in the standard!  This is why I don't want to change anything until the
wording of the standard is finalized.

There's also this part:

| If size is zero, then the block pointed to by memblock is freed; the
| return value is NULL, and memblock is left pointing at a freed block.

And I think Windows (well, the Microsoft C runtime, which is not an
integral part of Windows, as far as I understand it) also matches the
Bionic/glibc behavior for malloc, not just for realloc:

| If size is 0, malloc allocates a zero-length item in the heap and
| returns a valid pointer to that item.

<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/malloc?view=msvc-170>

Thanks,
Florian


Reply via email to