realloc(ptr, 0)
behavior is undefined. The vast majority of modern C libraries will implement it as return free(ptr), NULL;
and it will be documented on man pages as such, but there are systems where this will be equivalent to return free(ptr), malloc(0);
Furthermore, in theory, this is also permitted: return NULL;
so as tempting as realloc() might be as a single override for implementing custom allocators, there are some worms.