If it is constructive criticism that you seek, better to post over at
Code Review. That said, a couple of suggestions: it is imperative that code checks for success of calls to
malloc()
before attempting to use the allocation. In the same vein, it is a mistake to directly assign the result of
realloc()
to the pointer to the original memory being reallocated; if
realloc()
fails,
NULL
is returned, and code is left with a memory leak. It is much more efficient to double memory when resizing than to add 1 space at a time: fewer calls to
realloc()
. —
David Bowling 35 secs ago