Errors, Logging, Malloc and Testing in about 1000 lines of C.