Right now, the code assumes everything goes right, because it aborts when it doesn't.
I have attempted to do this but I have made far too many modifications on my fork to isolate them, plus I may not understand the code as well as I should.
Erroneous conditions should propagate (returning NULL from malloc and realloc), possibly setting errno as well.