No objections to your answer to the OP's question, but as a curiosity, I'm trying to figure out what the original xrealloc() function is trying to do.
So far as I can tell, it tries a normal realloc() with the requested size, but if that fails, tries again with size=1. But strangely, it that fails, tries using the requested size a second time. And if that still fails, tries once more with size=1.
The POSIX man page isn't giving me any hints as to why size=1 might be special, or if this is some sort of Linux-specific behavior or workaround. I wondered if you might have some insight why this function is the way it is.
Note: I'm on mobile, so haven't checked the Git Blame history yet.
Do computers aspire?