Nit: I would suggest not using assert() for checking error return values. Compiling the program with -DNDEBUG disables the check. assert() is for finding bugs in your program. A malloc() call returning NULL is not a bug.
Nit: I would suggest not using assert() for checking error return values. Compiling the program with -DNDEBUG disables the check. assert() is for finding bugs in your program. A malloc() call returning NULL is not a bug.